:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d2b1f;
  background: #f4f7f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --brand-950: #102813;
  --brand-900: #173f1b;
  --brand-800: #205526;
  --brand-700: #2a6b2f;
  --brand-600: #367f3d;
  --brand-500: #58a35f;
  --brand-200: #cce4ce;
  --brand-100: #e8f2e8;
  --brand-50: #f4f9f4;
  --sand-100: #f0e8dc;
  --sand-500: #b77b3f;
  --danger-100: #fbe9e7;
  --danger-600: #b23a32;
  --blue-100: #e5f0f7;
  --blue-600: #397a9b;
  --amber-100: #fff1d2;
  --amber-700: #95640f;
  --white: #fff;
  --text: #1d2b1f;
  --muted: #667167;
  --border: #dce4da;
  --shadow: 0 16px 40px rgba(32, 68, 35, 0.09);
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 100% 0, #eef5eb 0, transparent 34%), #f4f7f2; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
button { cursor: pointer; }
.page-loader { min-height: 100vh; display: grid; place-items: center; color: var(--brand-700); font-weight: 700; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 260px; position: fixed; inset: 0 auto 0 0; background: linear-gradient(180deg, var(--brand-950), #1c4c20); color: #fff; padding: 24px 18px 18px; display: flex; flex-direction: column; z-index: 40; box-shadow: 10px 0 30px rgba(16, 40, 19, .14); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #75bd6f, #2f7a35); box-shadow: 0 8px 18px rgba(0,0,0,.2); }
.brand strong { display: block; font-size: 22px; line-height: 1; letter-spacing: .01em; }
.brand span { display: block; color: #b9d7b9; font-size: 13px; margin-top: 4px; }
.brand--large .brand__mark { width: 58px; height: 58px; border-radius: 18px; }
.brand--large strong { font-size: 28px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 6px; margin-top: 38px; }
.nav-item { border: 0; width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: #dbe9db; background: transparent; transition: .18s ease; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item--active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 #91ce87; }
.nav-item--button { font-size: 14px; }
.sidebar__footer { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.12); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 0 8px 14px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #dcebd9; color: var(--brand-900); font-weight: 800; }
.user-card__text { min-width: 0; }
.user-card__text strong, .user-card__text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card__text strong { font-size: 13px; }
.user-card__text span { color: #b8cdb8; font-size: 11px; margin-top: 3px; }
.sidebar__close { display: none; position: absolute; right: 16px; top: 17px; color: #fff; background: rgba(255,255,255,.1); }
.sidebar-backdrop { display: none; }
.app-content { min-width: 0; flex: 1; margin-left: 260px; }
.topbar { height: 76px; position: sticky; top: 0; z-index: 20; background: rgba(248, 250, 246, .9); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(42,107,47,.1); display: flex; align-items: center; justify-content: space-between; padding: 0 34px; }
.topbar__title span, .topbar__title strong { display: block; }
.topbar__title span { color: var(--muted); font-size: 12px; }
.topbar__title strong { font-size: 15px; margin-top: 3px; }
.topbar__menu { display: none; }
.topbar__status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #43a047; box-shadow: 0 0 0 4px rgba(67,160,71,.12); }
.status-dot--demo { background: #d99a2b; box-shadow: 0 0 0 4px rgba(217,154,43,.12); }
.main-content { padding: 30px 34px 48px; max-width: 1680px; margin: 0 auto; }
.page-stack { display: flex; flex-direction: column; gap: 22px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-header h1 { font-size: clamp(28px, 3vw, 38px); margin: 3px 0 8px; letter-spacing: -.035em; color: #16351a; }
.page-header p { color: var(--muted); margin-bottom: 0; max-width: 720px; }
.page-header__actions { display: flex; gap: 10px; }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .13em; font-size: 10px; font-weight: 800; color: var(--brand-600); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: 12px; padding: 11px 16px; font-weight: 750; transition: .18s; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button--primary { background: var(--brand-700); color: white; box-shadow: 0 8px 22px rgba(42,107,47,.22); }
.button--primary:hover { background: var(--brand-800); transform: translateY(-1px); }
.button--secondary { background: white; color: var(--brand-800); border-color: var(--border); }
.button--full { width: 100%; }
.icon-button { border: 0; background: #fff; color: var(--brand-800); width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; box-shadow: 0 4px 14px rgba(30,60,32,.08); }
.text-link { color: var(--brand-700); font-weight: 750; font-size: 13px; }
.panel { background: rgba(255,255,255,.94); border: 1px solid rgba(42,107,47,.11); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.panel__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 15px; }
.panel__header h2, .panel h2 { color: #17391c; margin: 4px 0 0; font-size: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 24px rgba(40,70,40,.05); }
.stat-card__icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); }
.stat-card--blue .stat-card__icon { background: var(--blue-100); color: var(--blue-600); }
.stat-card--amber .stat-card__icon { background: var(--amber-100); color: var(--amber-700); }
.stat-card--red .stat-card__icon { background: var(--danger-100); color: var(--danger-600); }
.stat-card span, .stat-card strong, .stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 27px; margin: 2px 0; }
.stat-card small { color: #869087; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(360px, .75fr); gap: 20px; }
.panel--map .map-frame { height: 490px; }
.map-frame { position: relative; height: 100%; min-height: 390px; border-radius: 14px; overflow: hidden; background: #e6eee4; }
.field-map { height: 100%; width: 100%; z-index: 1; }
.map-empty { position: absolute; z-index: 3; left: 16px; bottom: 16px; max-width: 360px; background: rgba(255,255,255,.92); padding: 10px 12px; border-radius: 10px; color: var(--muted); font-size: 12px; }
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 24px 1fr; gap: 8px; position: relative; }
.timeline-item__rail { color: var(--brand-600); padding-top: 20px; position: relative; }
.timeline-item:not(:last-of-type) .timeline-item__rail::after { content: ''; position: absolute; left: 7px; top: 35px; bottom: -10px; width: 2px; background: var(--brand-200); }
.timeline-card { margin: 7px 0; padding: 13px 15px; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 13px; }
.timeline-card__meta { color: var(--muted); font-size: 11px; }
.timeline-card h3 { font-size: 15px; margin: 5px 0; }
.timeline-card p { margin: 0; color: #536056; font-size: 13px; line-height: 1.45; }
.timeline-card--origin { background: #f4eadc; border-color: #e2cfb4; }
.timeline-item--origin .timeline-item__rail { color: #a76f32; }
.timeline-more { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; margin: 6px 0 0 24px; }
.empty-state { padding: 34px 18px; display: grid; justify-items: center; text-align: center; color: var(--muted); gap: 7px; }
.empty-state strong { color: var(--text); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, .65fr); gap: 20px; min-height: 700px; }
.workspace-map { display: flex; flex-direction: column; gap: 14px; }
.workspace-map .map-frame { flex: 1; }
.toolbar { display: flex; align-items: center; gap: 12px; }
.search-box { flex: 1; display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: #f8faf7; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; }
.result-count { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.field-inspector { overflow: auto; }
.field-inspector__hero { display: flex; gap: 12px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.field-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--brand-100); color: var(--brand-700); }
.alert-banner, .warning-box { display: flex; gap: 10px; align-items: flex-start; background: var(--danger-100); color: var(--danger-600); padding: 12px; border-radius: 12px; margin: 16px 0; }
.warning-box { background: var(--amber-100); color: var(--amber-700); }
.warning-box span, .warning-box strong { display: block; }
.detail-list { margin: 16px 0 22px; }
.detail-list > div { padding: 11px 0; border-bottom: 1px solid #edf0ec; }
.detail-list dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.detail-list dd { margin: 5px 0 0; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.field-list, .field-selector__list { display: flex; flex-direction: column; gap: 7px; max-height: 430px; overflow: auto; }
.field-list-item { width: 100%; border: 1px solid transparent; border-radius: 12px; background: transparent; display: flex; align-items: center; gap: 10px; padding: 10px; text-align: left; }
.field-list-item:hover, .field-list-item--active { background: var(--brand-50); border-color: var(--brand-200); }
.field-list-item strong, .field-list-item small { display: block; }
.field-list-item small { color: var(--muted); margin-top: 3px; }
.field-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-500); }
.field-dot--danger { background: var(--danger-600); }
.date-navigator { align-self: center; display: flex; align-items: center; gap: 14px; padding: 8px; background: white; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.date-navigator label { display: grid; min-width: 225px; text-align: center; cursor: pointer; }
.date-navigator label span { text-transform: capitalize; color: var(--muted); font-size: 11px; }
.date-navigator label strong { margin-top: 3px; }
.date-navigator input { position: absolute; opacity: 0; pointer-events: none; }
.records-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .75fr); gap: 20px; min-height: 650px; }
.records-map { display: flex; flex-direction: column; gap: 14px; }
.records-map .map-frame { flex: 1; }
.field-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 7px 12px; border-radius: 999px; }
.chip--selected { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.records-timeline { overflow: auto; }
.context-event { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: #f3f5f2; border-left: 4px solid #96a096; }
.context-event--future { background: var(--blue-100); border-color: var(--blue-600); }
.context-event span, .context-event strong, .context-event small { display: block; }
.context-event span { color: var(--muted); font-size: 11px; }
.context-event strong { margin: 3px 0; }
.activity-picker { padding: 17px; }
.activity-picker__grid { display: grid; grid-template-columns: repeat(8, minmax(105px, 1fr)); gap: 9px; margin-top: 10px; overflow-x: auto; }
.activity-option { border: 1px solid var(--border); background: #fff; color: #536056; border-radius: 13px; padding: 13px 10px; display: grid; justify-items: center; gap: 7px; white-space: nowrap; }
.activity-option--active { border-color: var(--brand-600); background: var(--brand-100); color: var(--brand-800); box-shadow: inset 0 0 0 1px var(--brand-600); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-label { color: #425045; font-size: 12px; font-weight: 700; display: grid; gap: 7px; }
.field-label input, .field-label textarea, .field-label select { border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; background: #fbfcfa; outline: none; }
.field-label input:focus, .field-label textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(88,163,95,.12); }
.field-label--wide { grid-column: 1 / -1; }
.activity-form { transition: opacity .2s, filter .2s; }
.activity-form header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.activity-form header > div { display: flex; align-items: center; gap: 12px; color: var(--brand-700); }
.activity-form h2 { font-size: 17px; }
.activity-form p { color: var(--muted); font-size: 13px; }
.activity-form--disabled { filter: grayscale(1); opacity: .53; background: #f2f3f1; }
.toggle-form { border: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #eef2ed; color: var(--muted); }
.check-row { display: flex; gap: 9px; align-items: center; font-size: 14px; }
.field-selector { position: sticky; top: 98px; }
.field-selector p { color: var(--muted); font-size: 13px; }
.select-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.select-row--active { border-color: var(--brand-500); background: var(--brand-50); }
.select-row strong, .select-row small { display: block; }
.select-row small { color: var(--muted); margin-top: 2px; }
.toast-message { position: fixed; right: 22px; bottom: 22px; padding: 12px 16px; color: #fff; background: #243526; border-radius: 12px; box-shadow: var(--shadow); z-index: 80; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .65fr); gap: 20px; align-items: start; }
.report-config h2 { font-size: 17px; margin: 8px 0 13px; }
.report-config .field-selector__list { max-height: 330px; margin-bottom: 16px; }
.report-preview { position: sticky; top: 98px; background: #e9eee7; }
.report-preview__paper { background: #fff; max-width: 470px; min-height: 580px; margin: 0 auto; padding: 38px; box-shadow: 0 10px 32px rgba(25,50,25,.14); }
.report-preview__paper h2 { font-size: 26px; margin: 10px 0 4px; }
.report-preview__paper h3 { font-size: 14px; color: var(--muted); }
.report-preview__paper dl > div { display: flex; justify-content: space-between; border-bottom: 1px solid #e8ece7; padding: 10px 0; }
.report-preview__paper dt { color: var(--muted); }
.report-preview__paper dd { margin: 0; font-weight: 700; }
.paper-lines { margin-top: 28px; display: grid; gap: 10px; }
.paper-lines span { height: 34px; padding: 9px; background: var(--brand-50); border-left: 3px solid var(--brand-700); font-size: 12px; }
.desktop-hint { display: flex; gap: 9px; color: var(--muted); font-size: 12px; margin-top: 16px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(560px, 1.2fr); gap: 20px; }
.chart-wrap { height: 410px; }
.table-scroll { overflow: auto; max-height: 420px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; padding: 10px; border-bottom: 1px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid #edf0ec; font-size: 13px; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.25fr) minmax(400px, .75fr); }
.login-visual { padding: 54px; color: #fff; background: radial-gradient(circle at 70% 20%, rgba(130,195,120,.35), transparent 24%), linear-gradient(135deg, #102813, #2a6b2f 66%, #417d43); position: relative; overflow: hidden; }
.login-visual::after { content: ''; position: absolute; inset: auto -10% -20% -10%; height: 48%; border-radius: 50% 50% 0 0; background: linear-gradient(170deg, rgba(129,177,94,.6), rgba(39,91,43,.7)); transform: rotate(-4deg); }
.login-visual__content { max-width: 620px; position: relative; z-index: 2; }
.login-visual h1 { font-size: clamp(38px, 5vw, 67px); line-height: 1.04; letter-spacing: -.05em; margin: 100px 0 22px; }
.login-visual p { font-size: 18px; line-height: 1.65; color: #dcebdc; max-width: 550px; }
.login-visual__landscape { display: flex; gap: 7px; position: absolute; top: 470px; left: 0; transform: rotate(-8deg); }
.login-visual__landscape span { width: 190px; height: 10px; border-radius: 999px; background: rgba(255,255,255,.18); }
.login-panel { display: grid; place-items: center; padding: 40px; background: #f8faf6; }
.login-card { width: min(100%, 430px); background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 31px; margin: 7px 0; }
.login-card > p { color: var(--muted); margin-bottom: 28px; }
.login-card .field-label { margin-bottom: 16px; }
.input-with-icon { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.input-with-icon input { border: 0; flex: 1; padding: 12px 4px; outline: 0; }
.form-error { padding: 11px 13px; border-radius: 10px; background: var(--danger-100); color: var(--danger-600); margin-bottom: 12px; }
.demo-note { margin-top: 14px; padding: 10px; background: var(--amber-100); color: var(--amber-700); border-radius: 10px; font-size: 12px; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .workspace-grid, .records-layout, .admin-grid { grid-template-columns: 1fr; }
  .field-inspector { max-height: none; }
  .editor-layout { grid-template-columns: 1fr; }
  .field-selector, .report-preview { position: static; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar--open { transform: translateX(0); }
  .sidebar__close { display: grid; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(8,20,10,.5); }
  .app-content { margin-left: 0; }
  .topbar { padding: 0 18px; }
  .topbar__menu { display: grid; }
  .main-content { padding: 24px 18px 40px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .report-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-label--wide { grid-column: auto; }
  .page-header__actions, .page-header__actions .button { width: 100%; }
  .topbar__title { display: none; }
  .activity-picker__grid { grid-template-columns: repeat(8, 105px); }
  .login-panel { padding: 18px; }
  .login-card { padding: 25px; }
}

/* Firestore field/map compatibility */
.field-list { display: grid; gap: 10px; }
.field-list-item { width: 100%; border: 1px solid var(--border); border-radius: 13px; background: #fff; padding: 13px 14px; text-align: left; color: var(--text); transition: .18s ease; }
.field-list-item:hover, .field-list-item--active { border-color: var(--brand-500); background: var(--brand-50); transform: translateY(-1px); }
.field-list-item__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-list-item > span, .field-list-item > small { display: block; margin-top: 5px; color: var(--muted); }
.field-list-item strong { color: var(--brand-900); }
.field-alert-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--danger-600); box-shadow: 0 0 0 4px var(--danger-100); }
.leaflet-popup-content strong { color: var(--brand-900); }

/* --------------------------------------------------------------------------
   Campo-style desktop refresh — presentation only, no Firestore schema changes
   -------------------------------------------------------------------------- */
:root {
  --brand-950: #073e2e;
  --brand-900: #0b4a35;
  --brand-800: #0f5a3b;
  --brand-700: #146a43;
  --brand-600: #247c4d;
  --brand-500: #4f9664;
  --brand-200: #cfe2cf;
  --brand-100: #e7f0e3;
  --brand-50: #f4f8f1;
  --surface: #f7f8f5;
  --border: #d7ded6;
  --shadow: 0 9px 28px rgba(24, 56, 37, .08);
  --radius: 13px;
}

body.django-shell { background: var(--surface); color: #172019; }
.django-shell .sidebar { width: 236px; padding: 28px 12px 17px; background: linear-gradient(180deg, #074735 0%, #063a2d 100%); box-shadow: none; }
.django-shell .app-content { margin-left: 236px; }
.django-shell .brand--campo { padding: 2px 14px 18px; gap: 9px; color: #fff; }
.brand__leaf { width: 43px; height: 43px; display: grid; place-items: center; color: #d9f0cf; }
.brand__leaf svg { width: 100%; height: 100%; }
.brand__copy strong { display: block; font-size: 21px; line-height: 1; letter-spacing: -.025em; }
.brand__copy span { display: block; color: #c5ddcf; font-size: 12px; margin-top: 4px; }
.django-shell .sidebar__nav { margin-top: 20px; gap: 4px; }
.django-shell .nav-item { min-height: 47px; border-radius: 9px; padding: 10px 13px; color: #e0ebe4; font-size: 14px; font-weight: 600; }
.django-shell .nav-item:hover { background: rgba(255,255,255,.08); }
.django-shell .nav-item--active { background: linear-gradient(90deg, rgba(183,220,179,.32), rgba(183,220,179,.16)); box-shadow: none; color: #fff; }
.nav-item__icon { width: 25px; height: 25px; flex: 0 0 25px; display: grid; place-items: center; }
.nav-item__icon svg, .button__icon, .summary-strip__icon svg, .field-summary-card__icon svg, .alert-card__icon svg, .field-list-item__icon svg, .map-layer-tab svg, .topbar__menu svg {
  width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.django-shell .sidebar__footer { padding-top: 14px; }
.sidebar__connection { display: flex; align-items: center; gap: 8px; color: #bcd3c4; font-size: 11px; padding: 0 10px 13px; }
.django-shell .user-card { padding: 10px 8px; }
.django-shell .avatar { background: #e7efe5; color: #0b4a35; }
.django-shell .user-card__text strong { font-size: 13px; }
.django-shell .nav-item--logout { margin-top: 3px; color: #c9dbd0; }

.django-shell .topbar { height: 58px; padding: 0 30px; background: rgba(247,248,245,.94); border-bottom: 0; }
.django-shell .topbar__title { opacity: .72; }
.django-shell .topbar__status { border: 1px solid #d5dfd2; border-radius: 999px; padding: 6px 10px; background: #eef4e9; color: #435147; }
.django-shell .main-content { max-width: 1560px; padding: 24px 28px 46px; }
.django-shell .page-stack { gap: 17px; }
.django-shell .page-header { align-items: center; }
.django-shell .page-header h1 { margin: 0 0 3px; color: #153a2a; font-size: clamp(29px, 2.5vw, 39px); }
.django-shell .page-header p { font-size: 14px; }
.django-shell .button { min-height: 43px; border-radius: 8px; padding: 10px 16px; }
.django-shell .button--primary { background: #0e6943; box-shadow: none; }
.django-shell .button--secondary { border-color: #1d7450; color: #155f42; background: #fff; }
.button__icon { width: 21px; height: 21px; }
.django-shell .panel { padding: 16px; border-radius: 12px; border-color: #d8ded7; box-shadow: 0 3px 12px rgba(27,53,34,.05); background: rgba(255,255,255,.97); }
.panel__header--compact { margin-bottom: 10px; align-items: center; }
.panel__header--compact h2 { margin: 0; font-size: 20px; color: #17251c; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.simple-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.field-card { padding: 16px; border: 1px solid var(--border); border-radius: 14px; background:#fff; }
.field-card small { color: var(--muted); }
.tag { display:inline-flex; padding:4px 8px; border-radius:999px; background:var(--brand-100); color:var(--brand-800); font-size:11px; font-weight:700; }
.form-stack { display:grid; gap:14px; }
.form-stack input,.form-stack textarea,.form-stack select { width:100%; border:1px solid var(--border); border-radius:11px; padding:11px 12px; background:#fbfcfa; }
.check-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.check-grid label { border:1px solid var(--border); border-radius:11px; padding:10px; background:#fff; }
.message-list { display:grid; gap:8px; margin-bottom:14px; }
.message { padding:10px 12px; border-radius:10px; background:var(--brand-100); color:var(--brand-900); }

/* Dashboard */
.page-header--dashboard p { color: #4c5550; }
.summary-strip { display: flex; align-items: center; gap: 22px; min-height: 48px; padding: 0 7px; }
.summary-strip__item { display: flex; align-items: center; gap: 9px; font-size: 15px; color: #38433c; }
.summary-strip__item strong { color: #17221a; font-size: 21px; }
.summary-strip__item--warning .summary-strip__icon, .summary-strip__item--warning strong { color: #b76a0b; }
.summary-strip__icon { width: 25px; height: 25px; display: grid; color: #347f35; }
.summary-strip__divider { width: 1px; height: 29px; background: #ccd4cb; }
.dashboard-focus-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .78fr); gap: 14px; align-items: stretch; }
.map-explorer--dashboard { min-height: 500px; display: flex; flex-direction: column; }
.map-layer-tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.map-layer-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; border: 1px solid #d7ded6; border-radius: 8px; background: #fff; color: #26342c; padding: 7px 13px; font-weight: 650; }
.map-layer-tab svg { width: 21px; height: 21px; color: #1a7042; }
.map-layer-tab.is-active { color: #fff; border-color: #2a7448; background: linear-gradient(180deg, #427d4f, #2a693c); box-shadow: 0 3px 8px rgba(31,85,49,.18); }
.map-layer-tab.is-active svg { color: #fff; }
.map-layer-tab.is-disabled { opacity: .45; cursor: not-allowed; }
.tab-count { min-width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 999px; background: rgba(255,255,255,.25); font-size: 11px; }
.map-frame--dashboard { flex: 1; min-height: 410px; }
.map-frame--workspace { flex: 1; min-height: 620px; }
.map-legend { position: absolute; z-index: 3; left: 12px; bottom: 12px; display: flex; gap: 13px; flex-wrap: wrap; padding: 8px 11px; border: 1px solid rgba(20,70,42,.14); border-radius: 8px; background: rgba(255,255,255,.92); box-shadow: 0 3px 10px rgba(20,60,35,.09); font-size: 11px; color: #354239; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 23px; height: 13px; }
.legend-field { border: 2px solid #1b7a2e; background: rgba(63,157,70,.16); }
.legend-infected { width: 13px !important; border-radius: 50%; background: #d13b34; border: 2px solid #fff; box-shadow: 0 0 0 1px #d13b34; }
.maplibregl-popup-content { border-radius: 10px; padding: 0; overflow: hidden; box-shadow: 0 10px 27px rgba(22,48,30,.18); }
.map-popup-card { min-width: 190px; padding: 13px 14px; display: grid; gap: 4px; color: #263129; }
.map-popup-card strong { color: #0d4b31; font-size: 14px; }
.map-popup-card > span:not(.map-popup-alert) { color: #68736b; font-size: 12px; }
.map-popup-card p { margin: 3px 0 0; color: #4b554e; font-size: 12px; }
.map-popup-alert { width: fit-content; padding: 3px 6px; border-radius: 999px; background: #f9dedb; color: #aa2e28; font-size: 10px; font-weight: 800; }
.map-load-error { height: 100%; display: grid; place-items: center; padding: 25px; color: #9c342e; background: #fff0ee; font-weight: 700; text-align: center; }
.alert-overview { min-height: 500px; }
.alert-list { display: grid; gap: 11px; }
.alert-card { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 13px; border: 1px solid #d9dfd7; border-radius: 10px; background: #fff; }
.alert-card__icon { width: 58px; height: 58px; border-radius: 10px; display: grid; place-items: center; padding: 14px; background: #ffe3ac; color: #a7620c; }
.alert-card__head { display: flex; justify-content: space-between; }
.alert-badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; background: #ffd27c; color: #70420b; font-size: 10px; font-weight: 800; }
.alert-card h3 { margin: 6px 0 4px; font-size: 16px; }
.alert-card p { margin: 0 0 7px; color: #616b64; font-size: 12px; line-height: 1.45; }
.alert-card a { color: #0e6341; font-weight: 750; font-size: 12px; }
.alert-empty { min-height: 250px; display: grid; place-items: center; align-content: center; gap: 7px; color: #657068; text-align: center; }
.alert-empty span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: #267744; background: #e4f1e0; font-size: 25px; }
.alert-empty strong { color: #1d3928; }
.alert-empty p { margin: 0; font-size: 12px; }
.dashboard-section { display: grid; gap: 9px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 5px; }
.section-heading h2 { margin: 0; font-size: 21px; }
.field-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.field-summary-card { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 76px; padding: 11px 14px; border: 1px solid #d8ded7; border-radius: 10px; background: #fff; box-shadow: 0 2px 8px rgba(26,57,37,.04); }
.field-summary-card__icon { width: 40px; height: 40px; color: #327d37; padding: 4px; }
.field-summary-card h3 { margin: 0 0 4px; font-size: 15px; }
.field-summary-card p { margin: 0; color: #667069; font-size: 12px; }
.field-status { padding: 6px 10px; border-radius: 8px; background: #e9f2e5; color: #2f6e37; font-size: 11px; font-weight: 750; white-space: nowrap; }
.field-status--warning { background: #ffe7ba; color: #9a5b08; }
.activity-table-panel { padding-bottom: 8px !important; }
.table-scroll--dashboard { max-height: none; }
.activity-table thead th { background: #e4ecdf; color: #26362c; letter-spacing: 0; text-transform: none; font-size: 12px; }
.activity-table td { color: #354039; }
.activity-table td:first-child { white-space: nowrap; }

/* Field page */
.workspace-grid--campo { grid-template-columns: minmax(0,1.7fr) minmax(310px,.62fr); min-height: 700px; }
.field-inspector--campo { max-height: 760px; }
.field-list-item { display: flex !important; align-items: center !important; gap: 10px !important; padding: 11px !important; background: #fff !important; border-color: #e0e5df !important; }
.field-list-item__icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; color: #2f7d3b; }
.field-list-item__body { min-width: 0; flex: 1; }
.field-list-item__body > span, .field-list-item__body > small { display: block; margin-top: 3px; color: var(--muted); }
.field-list-item:hover, .field-list-item--active { background: #eff6ec !important; border-color: #75a978 !important; transform: none !important; }

/* Report workspace */
.data-source-pill { padding: 8px 13px; border-radius: 8px; background: #e5efdf; color: #2b5936; font-size: 12px; font-weight: 700; }
.report-workspace { display: grid; grid-template-columns: 355px minmax(0,1fr); gap: 12px; align-items: start; }
.report-filters { padding: 15px 18px !important; }
.report-section-title { padding: 0 0 9px; border-bottom: 1px solid #ccd5cb; }
.report-section-title h2 { margin: 0; font-size: 19px; }
.filter-section { margin: 0; padding: 12px 0; border: 0; border-bottom: 1px solid #ccd5cb; }
.filter-section legend { padding: 0; margin-bottom: 8px; color: #1d2820; font-weight: 800; font-size: 14px; }
.report-check-list { display: grid; gap: 7px; max-height: 224px; overflow: auto; padding-right: 4px; }
.report-check-list--compact { max-height: 175px; }
.report-check-row { display: grid; grid-template-columns: 20px 1fr; gap: 9px; align-items: start; cursor: pointer; }
.report-check-row input { position: absolute; opacity: 0; }
.custom-check { width: 19px; height: 19px; margin-top: 1px; border: 1px solid #99a49c; border-radius: 5px; background: #fff; position: relative; }
.report-check-row input:checked + .custom-check { border-color: #176943; background: #176943; }
.report-check-row input:checked + .custom-check::after { content: ''; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.report-check-row strong, .report-check-row small { display: block; }
.report-check-row strong { color: #252e28; font-size: 13px; }
.report-check-row small { margin-top: 2px; color: #69736c; font-size: 11px; }
.date-filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.date-filter-grid label { color: #2d3730; font-size: 11px; font-weight: 700; }
.date-filter-grid input { width: 100%; margin-top: 5px; border: 1px solid #cfd6ce; border-radius: 7px; padding: 9px; background: #fff; color: #202923; }
.report-filter-summary { margin: 12px 0 9px; padding: 9px; border-radius: 8px; background: #eaf2df; color: #27623b; text-align: center; font-size: 12px; }
.report-preview-shell { padding: 0 !important; overflow: hidden; }
.report-preview-toolbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 17px; border-bottom: 1px solid #dce2db; }
.report-preview-toolbar > div { display: flex; align-items: baseline; gap: 15px; }
.report-preview-toolbar h2 { margin: 0; font-size: 20px; }
.report-preview-toolbar span { color: var(--muted); font-size: 12px; }
.report-paper-wrap { padding: 15px; background: #edf1eb; overflow: auto; }
.report-paper { width: min(100%, 870px); min-height: 620px; margin: 0 auto; padding: 28px 30px 18px; background: #fff; box-shadow: 0 8px 24px rgba(34,55,39,.14); color: #202522; }
.report-paper__header { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #343a36; font-size: 11px; font-weight: 800; }
.report-paper__brand { display: flex; align-items: center; gap: 7px; color: #0c633c; font-size: 19px; }
.report-paper__leaf { width: 33px; height: 33px; border: 2px solid #2d944a; border-radius: 50% 50% 50% 10px; display: grid; place-items: center; transform: rotate(-12deg); }
.report-paper__rule { height: 2px; margin: 12px 0 18px; background: #d5e4d0; }
.report-paper > h2 { margin: 0 0 4px; color: #123c2a; font-size: 31px; }
.report-paper__period { margin: 0; color: #56605a; font-size: 15px; }
.report-paper__summary { display: grid; grid-template-columns: minmax(0,1fr) 135px 110px; gap: 0; align-items: center; margin: 16px 0 14px; }
.report-paper__selection p { margin: 4px 0; font-size: 12px; }
.report-kpi { min-height: 58px; padding-left: 18px; border-left: 1px solid #cbd9c6; }
.report-kpi strong { display: block; color: #0f693d; font-size: 27px; line-height: 1; }
.report-kpi span { display: block; margin-top: 4px; color: #2e3732; font-size: 11px; line-height: 1.15; }
.report-table-wrap { overflow: auto; }
.report-table th { padding: 8px 10px; background: #dfead9; color: #1f2b22; text-transform: none; letter-spacing: 0; font-size: 12px; }
.report-table td { padding: 8px 10px; font-size: 11px; }
.report-paper__continuation { margin: 12px 0 0; color: #6d766f; font-size: 11px; font-style: italic; }
.report-paper__footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 25px; padding-top: 10px; border-top: 1px solid #d4e0d1; color: #6a736d; font-size: 10px; }

@media (max-width: 1250px) {
  .dashboard-focus-grid { grid-template-columns: 1fr; }
  .alert-overview { min-height: auto; }
  .field-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .report-workspace { grid-template-columns: 320px minmax(0,1fr); }
}
@media (max-width: 980px) {
  .report-workspace { grid-template-columns: 1fr; }
  .report-preview-shell { position: static; }
  .workspace-grid--campo { grid-template-columns: 1fr; }
  .map-frame--workspace { min-height: 470px; }
}
@media (max-width: 860px) {
  .django-shell .app-content { margin-left: 0; }
  .django-shell .sidebar { transform: translateX(-102%); }
  .django-shell .sidebar--open { transform: translateX(0); }
  .sidebar-backdrop--visible { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5,29,20,.52); }
  .django-shell .topbar__menu { display: grid; width: 39px; height: 39px; }
  .django-shell .sidebar__close { display: grid; }
  .summary-strip { flex-wrap: wrap; }
  .summary-strip__divider { display: none; }
  .field-summary-grid { grid-template-columns: 1fr; }
  .report-paper__summary { grid-template-columns: 1fr 100px; }
  .report-kpi:last-child { display: none; }
}
@media (max-width: 620px) {
  .django-shell .main-content { padding: 18px 13px 35px; }
  .django-shell .topbar { padding: 0 13px; }
  .summary-strip { gap: 10px 18px; }
  .summary-strip__item { min-width: calc(50% - 12px); }
  .map-layer-tab { flex: 1; justify-content: center; }
  .map-frame--dashboard { min-height: 360px; }
  .alert-card { grid-template-columns: 45px 1fr; }
  .alert-card__icon { width: 45px; height: 45px; padding: 10px; }
  .field-summary-card { grid-template-columns: 40px minmax(0,1fr); }
  .field-status { grid-column: 2; width: fit-content; }
  .report-paper { padding: 20px 15px 14px; min-width: 680px; }
  .report-paper-wrap { overflow-x: auto; }
  .date-filter-grid { grid-template-columns: 1fr; }
  .simple-grid,.check-grid { grid-template-columns:1fr; }
}

/* Sidebar responsive controls: keep action buttons hidden on desktop and make the
   mobile backdrop inert until the sidebar is actually open. */
.icon-button.topbar__menu,
.icon-button.sidebar__close {
  display: none;
}

.sidebar-backdrop {
  display: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 860px) {
  .icon-button.topbar__menu,
  .icon-button.sidebar__close {
    display: inline-grid;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    background: rgba(5, 29, 20, .52);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
  }

  .sidebar-backdrop.sidebar-backdrop--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
  }
}

/* Map startup is intentionally deferred until after the first UI paint. */
.field-map { position: relative; }
.field-map--loading::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 7;
  background: linear-gradient(110deg, #e8efe5 8%, #f6f8f4 18%, #e8efe5 33%);
  background-size: 200% 100%;
  animation: demeter-map-loading 1.25s linear infinite;
  pointer-events: none;
}
.field-map--loading::after {
  content: 'Preparando mapa…';
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #31523a;
  box-shadow: 0 5px 18px rgba(25,55,31,.10);
  font-size: 12px;
  font-weight: 750;
  pointer-events: none;
}
@keyframes demeter-map-loading {
  to { background-position-x: -200%; }
}
@media (prefers-reduced-motion: reduce) {
  .field-map--loading::before { animation: none; }
}
