/* AgroMaps IA — Legible, responsive, mobile-first */

:root {
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --success: #4ade80;
    --warning: #facc15;
    --danger: #f87171;
    --purple: #c084fc;
    --sidebar-w: 260px;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; height: auto; }

.main-content { min-height: 100vh; min-height: 100dvh; }
.main-content.has-sidebar { margin-left: var(--sidebar-w); }
.main-content.is-map {
    margin-left: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: 0;
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 3000;
    width: var(--tap);
    height: var(--tap);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1999;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    z-index: 2000;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text);
    text-decoration: none;
    font-size: 1.125rem;
}

.brand-text strong { color: var(--accent); font-weight: 700; }

.sidebar-nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }

.nav-item {
    display: block;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
}

.nav-item:hover, .nav-item.active {
    background: var(--nav-hover, #334155);
    color: var(--text);
    text-decoration: none;
}

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 1rem; }
.user-name { font-weight: 600; font-size: 1rem; }
.user-role { color: var(--text-muted); font-size: .9375rem; margin: .25rem 0 .75rem; }
.sidebar-guest-note { color: var(--text-muted); font-size: .9375rem; line-height: 1.45; }

.glass, .map-header, .map-panel, .alerts-panel, .map-stats, .modal-content, .modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: var(--tap);
    padding: .625rem 1rem;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--accent-dark); color: #fff; }
.btn-primary:hover { background: #0369a1; text-decoration: none; }
.btn-glass { background: #334155; color: var(--text); border: 1px solid var(--border); }
.btn-sm { min-height: 38px; padding: .45rem .85rem; font-size: .9375rem; }
.btn-block { width: 100%; }
.btn-success { background: #16a34a; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }

.field-label, .form-group label {
    display: block;
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: .35rem;
}

.form-group { margin-bottom: 1rem; }

.form-group input,
.form-group select,
.form-group textarea,
.select-field {
    width: 100%;
    min-height: var(--tap);
    padding: .65rem .85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.select-field:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}
.alert-error { background: #450a0a; color: #fecaca; border-color: #991b1b; }
.alert-success { background: #052e16; color: #bbf7d0; border-color: #166534; }
.alert-info { background: #0c4a6e; color: #bae6fd; border-color: #0369a1; }

.text-muted { color: var(--text-muted); font-size: 1rem; }

.auth-page { min-height: 100vh; }
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2rem 1.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.auth-logo { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: .5rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-links { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; margin-top: 1rem; font-size: .9375rem; }
.demo-credentials { text-align: center; margin-top: 1rem; color: var(--text-muted); font-size: .9375rem; }

.map-page { overflow: hidden; }

.map-app {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #1a2332;
}

.agromaps-map {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #1a2332;
}

.agromaps-map .leaflet-container,
.agromaps-map .leaflet-pane,
.agromaps-map .leaflet-map-pane,
.agromaps-map .leaflet-tile-pane {
    width: 100% !important;
    height: 100% !important;
}

.map-fallback-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    z-index: 0;
}

.map-fallback-iframe.hidden { display: none; }

.map-loading {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(15, 23, 42, .88);
    color: var(--text);
    font-size: 1.0625rem;
    pointer-events: none;
}

.map-loading.hidden { display: none; }

.map-loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #334155;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.map-error {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    max-width: min(92%, 420px);
    padding: 1rem 1.25rem;
    background: #450a0a;
    color: #fecaca;
    border: 1px solid #991b1b;
    border-radius: var(--radius);
    font-size: 1rem;
    text-align: center;
}

.map-ui { z-index: 100; pointer-events: none; }
.map-ui > * { pointer-events: auto; }

.radar-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: .12;
}
.radar-overlay.hidden { display: none; }
.radar-sweep {
    position: absolute;
    top: 50%; left: 50%;
    width: 150vmax; height: 150vmax;
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg, transparent, rgba(56,189,248,.15), transparent);
    border-radius: 50%;
    animation: radar 8s linear infinite;
}
@keyframes radar { to { transform: translate(-50%,-50%) rotate(360deg); } }

.map-header {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    padding: .75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.map-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.map-header-left { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--success);
}

.pulse { width: 10px; height: 10px; background: var(--success); border-radius: 50%; }

.map-header-right { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.map-provider-badge {
    font-size: .8125rem;
    color: var(--text-muted);
    padding: .2rem .5rem;
    background: #0f172a;
    border-radius: 6px;
}

.map-panel, .alerts-panel {
    position: absolute;
    top: 88px;
    width: min(320px, calc(100% - 24px));
    max-height: calc(100% - 180px);
    overflow: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

.map-panel { left: 12px; }
.alerts-panel { right: 12px; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
}

.panel-title { font-size: 1.0625rem; font-weight: 700; color: var(--text); }
.panel-subtitle { font-size: .9375rem; font-weight: 700; color: var(--text-soft); margin: 1rem 0 .5rem; }

.panel-close {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0f172a;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
}

.layer-toggles { display: flex; flex-direction: column; gap: .35rem; }

.layer-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .65rem;
    border-radius: 8px;
    font-size: .9375rem;
    color: var(--text-soft);
    cursor: pointer;
}

.layer-toggle:hover, .layer-toggle.active { background: #334155; color: var(--text); }
.layer-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.legend-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .9375rem;
    color: var(--text-soft);
    padding: .2rem 0;
}

.legend-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }

.map-filters { display: flex; flex-direction: column; gap: .65rem; }

.alert-card {
    padding: .85rem;
    margin-bottom: .5rem;
    border-radius: 8px;
    background: #0f172a;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    cursor: pointer;
}

.alert-card.severity-4, .alert-card.severity-5 { border-left-color: var(--danger); }
.alert-card-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.alert-card-msg { font-size: .9375rem; color: var(--text-muted); margin-top: .35rem; line-height: 1.45; }
.alert-card-time { font-size: .8125rem; color: var(--text-muted); margin-top: .35rem; }

.map-stats {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    padding: .65rem .85rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: .5rem 1rem;
}

.stat-item { text-align: center; min-width: 70px; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: .8125rem; color: var(--text-muted); }

.map-mobile-bar {
    display: none;
    position: absolute;
    top: 72px;
    left: 12px;
    z-index: 110;
    gap: .5rem;
}

.btn-map-mobile { min-height: 38px; padding: .4rem .75rem; font-size: .9375rem; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: rgba(0,0,0,.65);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.open { display: flex; }
.modal-content, .modal-box {
    width: min(560px, 100%);
    max-height: 85vh;
    overflow: auto;
    padding: 1.25rem;
    position: relative;
    color: var(--text);
}
.modal-close, .modal-x {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #334155;
    color: var(--text);
    font-size: 1.35rem;
    cursor: pointer;
}

.leaflet-container { font-family: var(--font) !important; font-size: 1rem !important; }
.leaflet-popup-content-wrapper {
    background: var(--bg-panel) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
}
.leaflet-popup-content { font-size: .9375rem !important; line-height: 1.45 !important; margin: 12px 14px !important; }
.leaflet-popup-tip { background: var(--bg-panel) !important; }
.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    font-size: 1.125rem !important;
    line-height: 28px !important;
}

.page-container { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: clamp(1.35rem, 4vw, 1.85rem); font-weight: 700; margin-bottom: .35rem; }
.page-header p { color: var(--text-muted); font-size: 1rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card, .dashboard-section, .report-form {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-card-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.stat-card-label { color: var(--text-muted); font-size: .9375rem; margin-top: .25rem; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1rem;
}

.dashboard-section h2 { font-size: 1.125rem; margin-bottom: 1rem; color: var(--accent); }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; font-size: .9375rem; min-width: 520px; }
.data-table th, .data-table td {
    padding: .75rem .65rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-soft);
}
.data-table th { color: var(--text-muted); font-weight: 600; }

.tag, .severity-badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 600;
}
.tag { background: #0c4a6e; color: #bae6fd; }
.severity-badge.s-1, .severity-badge.s-2 { background: #14532d; color: #bbf7d0; }
.severity-badge.s-3 { background: #713f12; color: #fef08a; }
.severity-badge.s-4 { background: #7f1d1d; color: #fecaca; }
.severity-badge.s-5 { background: #581c87; color: #e9d5ff; }

.mini-map { height: 280px; border: 1px solid var(--border); border-radius: var(--radius); margin-top: .75rem; }
.gps-box { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .5rem; }

.form-result { padding: 1rem; border-radius: var(--radius); margin-top: 1rem; font-size: 1rem; }
.form-result.success { background: #052e16; color: #bbf7d0; border: 1px solid #166534; }
.form-result.error { background: #450a0a; color: #fecaca; border: 1px solid #991b1b; }

.prediction-card { display: flex; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.prediction-prob { font-size: 1.35rem; font-weight: 700; color: var(--purple); min-width: 56px; }
.contributor-row { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .9375rem; }
.rank { color: var(--accent); font-weight: 700; margin-right: .5rem; }
.rep { color: var(--warning); font-weight: 600; }
.admin-report-card { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.admin-delete-form { display: inline-flex; margin: 0; }
.admin-subsection-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-soft);
    margin: 1.25rem 0 0.75rem;
}
.admin-subsection-title:first-of-type { margin-top: 0; }
.admin-reports-note { font-size: 0.875rem; margin: -0.35rem 0 1rem; }
.admin-reports-table { min-width: 640px; }
.admin-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.admin-inline-form { display: inline-flex; margin: 0; }
.status-tag-pending { background: #713f12; color: #fef08a; }
.status-tag-approved { background: #14532d; color: #bbf7d0; }
.status-tag-rejected { background: #450a0a; color: #fecaca; }
.status-tag-archived { background: #334155; color: #cbd5e1; }
#admin-reports { scroll-margin-top: 88px; }

.admin-flash {
    margin-bottom: 1rem;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .9375rem;
    border: 1px solid var(--border);
}
.admin-flash-success { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); color: #bbf7d0; }
.admin-flash-error { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #fecaca; }

.admin-ai-help { margin: 0 0 1rem; line-height: 1.5; font-size: .9rem; }
.admin-ai-help code { font-size: .85em; color: var(--accent); }
.admin-ai-form .admin-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    cursor: pointer;
}
.admin-ai-form .admin-check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.admin-form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    .admin-form-grid { grid-template-columns: 1fr 1fr; }
    .admin-form-grid > div:first-child { grid-column: 1 / -1; }
}
.field-hint { display: block; margin-top: 6px; color: var(--text-muted); font-size: .8125rem; }
.admin-form-actions { margin-top: 1rem; }
.ai-engine-badge {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.ai-status-on { color: #86efac; border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .1); }
.ai-status-off { color: #fcd34d; border-color: rgba(234, 179, 8, .35); background: rgba(234, 179, 8, .08); }

.admin-settings-wrap { scroll-margin-top: 80px; }
.admin-settings-form { display: flex; flex-direction: column; gap: 1.25rem; }
.admin-settings-block {
    margin: 0;
    padding: 0;
    border: 0;
}
.admin-settings-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.section-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}
.section-head-row h2 { margin-bottom: 0; }
.admin-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.admin-head-actions form { margin: 0; }
.dashboard-section-wide { grid-column: 1 / -1; }
.account-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
}
.account-summary-grid div,
.account-summary-grid .info-block {
    padding: .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--dash-inner-bg, rgba(15, 23, 42, .65));
}
.account-summary-grid span,
.ranking-metric span,
.ranking-score span {
    display: block;
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.account-summary-grid strong { display: block; margin-top: .2rem; color: var(--text); }
.account-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.inline-delete-form { display: inline-flex; }

.ranking-podium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.podium-card {
    min-height: 180px;
    padding: 1.25rem;
    border: 1px solid var(--rank-podium-border, rgba(56, 189, 248, .24));
    border-radius: var(--radius);
    background: var(--rank-podium-bg, linear-gradient(180deg, rgba(30, 41, 59, .94), rgba(15, 23, 42, .92)));
    box-shadow: var(--dash-card-shadow, 0 14px 36px rgba(0,0,0,.28));
    color: var(--rank-podium-text, var(--text));
}
.podium-1 { transform: translateY(-8px); border-color: rgba(250, 204, 21, .55); }
.podium-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 32px;
    margin-bottom: .75rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, .14);
    color: var(--accent);
    font-weight: 800;
}
.podium-card h2 {
    font-size: 1.12rem;
    margin-bottom: .25rem;
    color: var(--rank-podium-text, var(--text));
}
.podium-card p {
    color: var(--rank-podium-muted, var(--text-muted));
    margin-bottom: .85rem;
}
.podium-card strong {
    display: block;
    font-size: 1.55rem;
    color: var(--rank-podium-score, var(--warning));
}
.podium-card span:last-child {
    color: var(--rank-podium-muted, var(--text-muted));
}
.ranking-list { display: grid; gap: .65rem; }
.ranking-row {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 100px 100px 90px;
    align-items: center;
    gap: .75rem;
    padding: .85rem;
    border: 1px solid var(--rank-row-border, rgba(255,255,255,.07));
    border-radius: 10px;
    background: var(--rank-row-bg, rgba(15, 23, 42, .55));
    color: var(--text);
}
.ranking-place { color: var(--accent); font-weight: 800; }
.ranking-user strong {
    display: block;
    color: var(--text);
}
.ranking-user span {
    color: var(--text-muted);
    font-size: .9rem;
}
.ranking-metric strong,
.ranking-score strong {
    display: block;
    color: var(--text);
    font-size: 1.1rem;
}
.ranking-score strong {
    color: var(--rank-score-color, var(--warning));
}

.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    text-align: center;
}

@media (max-width: 1366px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar {
        transform: translateX(-105%);
        transition: transform .25s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .main-content.has-sidebar,
    .main-content.is-map { margin-left: 0; width: 100%; }
    .map-header { top: 58px; }
    .map-mobile-bar { display: flex; }
    .map-panel, .alerts-panel {
        top: auto;
        bottom: 72px;
        left: 12px;
        right: 12px;
        width: auto;
        max-height: 45vh;
        transform: translateY(120%);
        transition: transform .25s ease;
    }
    .map-panel.open, .alerts-panel.open { transform: translateY(0); }
    .panel-close { display: inline-flex; align-items: center; justify-content: center; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-container { padding: 1rem; padding-top: 4.5rem; }
    .report-simple-page .page-container { padding-top: 1rem; }
    .auth-card { padding: 1.5rem 1.15rem; }
}

/* ——— Reporte modal (una pantalla + voz + GPS) ——— */
.report-standalone-page { background: var(--bg); min-height: 100dvh; }
body.report-modal-open { overflow: hidden; }
body.map-layout.report-modal-open .map-body { pointer-events: none; }

.report-modal {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.report-modal[hidden] { display: none !important; }
.report-modal.open { display: flex; pointer-events: auto; }
.report-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    opacity: 0;
    transition: opacity .25s ease;
}
.report-modal.open .report-modal-backdrop { opacity: 1; }

.report-modal-sheet {
    position: relative;
    width: min(100%, 520px);
    max-height: min(96dvh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform .28s ease;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .35);
}
.report-modal.open .report-modal-sheet { transform: translateY(0); }

.report-modal-head {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 720px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
    .stat-card, .dashboard-section, .report-form { padding: 1rem; }
    .account-summary-grid { grid-template-columns: 1fr; }
    .section-head-row { align-items: stretch; flex-direction: column; }
    .section-head-row .btn { width: 100%; }
    .admin-report-card {
        display: grid;
        grid-template-columns: 1fr;
        padding: 1rem;
        margin-bottom: .75rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: rgba(15, 23, 42, .55);
    }
    .admin-actions,
    .admin-actions form,
    .admin-actions .btn { width: 100%; }
    .responsive-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 .75rem;
    }
    .responsive-table thead { display: none; }
    .responsive-table tr {
        display: block;
        padding: .75rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: rgba(15, 23, 42, .58);
    }
    .responsive-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border-bottom: 1px solid rgba(255,255,255,.06);
        padding: .55rem 0;
    }
    .responsive-table td:last-child { border-bottom: 0; }
    .responsive-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 700;
        flex: 0 0 38%;
    }
    .ranking-podium { grid-template-columns: 1fr; }
    .podium-1 { transform: none; }
    .ranking-row {
        grid-template-columns: 48px minmax(0, 1fr);
        grid-template-areas:
            "place user"
            "place reports"
            "place critical"
            "place score";
    }
    .ranking-place { grid-area: place; }
    .ranking-user { grid-area: user; }
    .ranking-reports { grid-area: reports; }
    .ranking-critical { grid-area: critical; }
    .ranking-score { grid-area: score; }
}
.report-flow-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--report-step-bar-bg, rgba(15, 23, 42, .72));
}
.report-step {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.report-step.is-active {
    border-color: var(--accent);
    color: #bae6fd;
    background: rgba(14, 116, 144, .28);
}
.report-step.is-done {
    border-color: #166534;
    color: #bbf7d0;
    background: rgba(5, 46, 22, .72);
}
.report-modal-head h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}
.report-modal-sub {
    font-size: .875rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.35;
}
.report-modal-x {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.report-modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 8px;
}
.report-modal-foot {
    flex-shrink: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.report-block { margin-bottom: 14px; }
.report-block-title {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--text-soft);
    margin-bottom: 8px;
}
.report-block-help {
    margin: -3px 0 8px;
    color: var(--text-muted);
    font-size: .82rem;
    line-height: 1.35;
}
.report-review-card {
    padding: 12px;
    border: 1px solid rgba(56, 189, 248, .24);
    border-radius: var(--radius);
    background: rgba(14, 116, 144, .12);
}
.report-review-card p { color: var(--text-soft); font-size: .92rem; }
.report-block-inline { margin-bottom: 8px; }

.report-choice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.report-choice-compact .choice-btn {
    min-height: 72px;
    padding: 8px 6px;
    gap: 4px;
}
.choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 88px;
    padding: 12px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
}
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.selected {
    border-color: var(--accent-dark, var(--accent));
    background: var(--choice-selected-bg, #0c4a6e);
    color: var(--choice-selected-text, #f8fafc);
}
.choice-icon { font-size: 1.5rem; line-height: 1; }
.choice-label { font-size: .8125rem; font-weight: 600; line-height: 1.2; }

.severity-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.severity-btn {
    min-height: 48px;
    padding: 10px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 700;
    cursor: pointer;
}
.severity-btn.selected {
    border-color: var(--accent-dark, var(--accent));
    background: var(--choice-selected-bg, #0c4a6e);
    color: var(--choice-selected-text, #f8fafc);
}

.field-simple {
    display: block;
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-soft);
    margin: 0 0 6px;
}
.optional { font-weight: 400; color: var(--text-muted); font-size: .8125rem; }
.field-input-simple {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
}
.field-input-simple::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.field-input-simple:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.voice-row { margin-bottom: 10px; }
.btn-voice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 12px 16px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: #0c4a6e;
    color: #fff;
    font-family: inherit;
    font-size: 1.0625rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-voice:disabled { opacity: .55; cursor: not-allowed; }
.btn-voice.is-listening {
    background: #991b1b;
    border-color: #ef4444;
    animation: voice-pulse 1.2s ease infinite;
}
@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}
.voice-icon { font-size: 1.35rem; }
.voice-hint { font-size: .8125rem; color: var(--text-muted); margin-top: 6px; line-height: 1.35; }

.photo-btn-wrap { display: block; cursor: pointer; }
.photo-btn-compact { margin-top: 0; }
.photo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-soft);
}
.photo-btn-wrap:hover .photo-btn { border-color: var(--accent); color: var(--accent); }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
.image-preview { margin-top: .5rem; }
.image-preview.has-photo img {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.gps-status-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-size: .9375rem;
    color: var(--text-muted);
    line-height: 1.35;
}
.gps-status-box.is-wait { border-color: var(--border); }
.gps-status-box.is-ok { border-color: #166534; color: #bbf7d0; background: #052e16; }
.gps-status-box.is-error { border-color: #991b1b; color: #fecaca; background: #450a0a; }
.gps-spinner {
    width: 18px; height: 18px; flex-shrink: 0;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.gps-spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.mini-map-compact { height: 200px; margin-top: 8px; }
.btn-gps { margin-bottom: 4px; min-height: 44px; }

.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.125rem; font-weight: 700; }

/* Submodales confirmar / éxito */
.report-submodal {
    position: fixed;
    inset: 0;
    z-index: 2600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.report-submodal.open {
    display: flex;
    pointer-events: auto;
}
.report-submodal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}
.report-submodal-box {
    position: relative;
    width: min(100%, 380px);
    padding: 24px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    text-align: center;
}
.report-submodal-box h2 { font-size: 1.25rem; margin-bottom: 8px; }
.report-submodal-box p { color: var(--text-muted); font-size: .9375rem; line-height: 1.45; margin-bottom: 16px; }
.report-submodal-actions {
    display: flex;
    gap: 10px;
}
.report-submodal-actions .btn { flex: 1; min-height: 48px; }
.report-submodal-success .success-icon {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #166534;
    color: #bbf7d0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 56px;
}

.report-toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
    z-index: 2700;
    padding: 14px 16px;
    border-radius: 10px;
    background: #1e293b;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: .9375rem;
    text-align: center;
    transform: translateY(120%);
    transition: transform .25s ease;
    pointer-events: none;
}
.report-toast.show { transform: translateY(0); }

#report-detail-modal.modal { z-index: 2400; }

@media (min-width: 600px) {
    .report-modal { align-items: center; padding: 16px; }
    .report-modal-sheet {
        border-radius: 16px;
        max-height: min(92dvh, 820px);
    }
}

@media (max-width: 380px) {
    .report-choice-grid { grid-template-columns: repeat(2, 1fr); }
    .severity-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .map-title { font-size: 1rem; }
    .map-header-right .btn-sm { padding: .4rem .6rem; font-size: .875rem; }
    .stat-value { font-size: 1.0625rem; }
}

/* Selector de idioma (sitio) — ver theme.css (.lang-dropdown) */
.sidebar-lang {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.site-lang-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-lang-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
