/* === RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* === MAP === */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* === SEARCH BAR === */
/* === MODE TABS === */
#top-bar {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 4px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

#mode-tabs {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.mode-tab {
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    transition: all 0.15s;
    white-space: nowrap;
}

.mode-tab:hover {
    background: #f0f0f0;
}

.mode-tab.active {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

/* === MODE PLACEHOLDER === */
#mode-placeholder {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999;
    background: rgba(255,255,255,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
}

#mode-placeholder.hidden {
    display: none;
}

.placeholder-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.placeholder-content h2 {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 12px;
}

.placeholder-content p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 8px;
}

/* === SEARCH BAR === */
#search-bar {
    display: flex;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

#search-input {
    flex: 1;
    min-width: 180px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

#search-input:focus {
    border-color: #4a90d9;
}

#search-btn {
    padding: 8px 16px;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#search-btn:hover {
    background: #357abd;
}

/* === LAYER CONTROLS === */
#layer-controls {
    position: absolute;
    top: 62px;
    left: 12px;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: calc(100% - 24px);
    background: white;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.layer-btn {
    padding: 5px 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #555;
    transition: all 0.15s;
    white-space: nowrap;
}

.layer-btn:hover {
    background: #f0f0f0;
}

.layer-btn.active {
    background: #4a90d9;
    color: white;
    border-color: #4a90d9;
}

/* More layers toggle */
.tool-btn-more {
    background: #f8f9fa;
    border: 1px dashed #aaa;
    color: #666;
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}
.tool-btn-more:hover {
    background: #e9ecef;
    border-color: #888;
}
.tool-btn-more.expanded {
    background: #e2e6ea;
    border-style: solid;
}

/* Extra layer controls (collapsed by default) */
#layer-controls-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 100%;
    padding-top: 4px;
    border-top: 1px solid #eee;
    margin-top: 2px;
}
#layer-controls-extra.collapsed {
    display: none;
}

/* === SIDEBAR === */
#sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 360px;
    height: 100%;
    background: white;
    z-index: 1001;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#sidebar.collapsed {
    transform: translateX(100%);
    visibility: hidden;
}

#sidebar-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    z-index: 1;
}

#sidebar-content {
    padding: 20px;
    padding-top: 40px;
}

#zone-title {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

/* Sidebar collapsible sections */
.sidebar-section {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fafbfc;
    overflow: hidden;
}
.sidebar-section summary {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-section summary::-webkit-details-marker { display: none; }
.sidebar-section summary::after {
    content: '▸';
    font-size: 12px;
    color: #999;
    transition: transform 0.2s;
}
.sidebar-section[open] summary::after {
    transform: rotate(90deg);
}
.sidebar-section .section-body {
    padding: 0 12px 10px;
    border-top: 1px solid #eee;
}

/* === SCORE DISPLAY === */
#score-display {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: #f8f8f8;
}

#score-number {
    font-size: 56px;
    font-weight: 700;
    line-height: 1;
}

#score-label {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* === SCORE BREAKDOWN === */
#score-breakdown {
    margin-bottom: 16px;
}

.breakdown-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.breakdown-label {
    width: 130px;
    color: #555;
    flex-shrink: 0;
}

.breakdown-bar {
    flex: 1;
    height: 16px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 8px;
}

.breakdown-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.breakdown-value {
    width: 36px;
    text-align: right;
    font-weight: 600;
    color: #333;
    flex-shrink: 0;
}

/* === ZONE STATS === */
#zone-stats {
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: #555;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

.stat-value-small {
    font-size: 11px;
    max-width: 140px;
    text-align: right;
}

.stat-section {
    font-size: 12px;
    font-weight: 600;
    color: #4a90d9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

/* === SIDEBAR COLLAPSIBLE FINANCIAL SECTIONS === */
.sidebar-collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-collapsible-header:hover {
    color: #3498db;
}
.sidebar-collapse-arrow {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
}
.sidebar-collapsible-teaser {
    cursor: pointer;
    padding: 2px 0;
}
.sidebar-collapsible-teaser:hover {
    background: #f7f9fc;
    border-radius: 4px;
}
.sidebar-collapsible-body {
    padding-bottom: 4px;
}
.sidebar-pl-teaser {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 4px 0;
}
.sidebar-pl-profit {
    font-weight: 700;
    font-size: 14px;
}
.sidebar-pl-margin {
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    margin-left: 4px;
}
.sidebar-pl-margin.positive { background: #e8f5e9; color: #2e7d32; }
.sidebar-pl-margin.negative { background: #fce4ec; color: #c62828; }
.sidebar-pl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin: 6px 0;
}
.sidebar-pl-table td {
    padding: 3px 4px;
    border-bottom: 1px solid #f5f5f5;
}
.sidebar-pl-table td:last-child {
    text-align: right;
    font-weight: 600;
}
.sidebar-pl-table .pl-total td {
    border-top: 1.5px solid #333;
    font-weight: 700;
}
.sidebar-pl-table .pl-profit td {
    font-weight: 700;
    font-size: 12px;
}
.sidebar-be-bar {
    position: relative;
    height: 14px;
    background: #eee;
    border-radius: 3px;
    overflow: visible;
    margin: 4px 0;
}
.sidebar-be-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.sidebar-be-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 18px;
    background: #333;
    border-radius: 1px;
    transform: translateX(-50%);
}
.sidebar-chain-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin: 6px 0;
}
.sidebar-chain-table th {
    background: #f7f8fa;
    padding: 4px 3px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1.5px solid #e0e0e0;
    font-size: 10px;
}
.sidebar-chain-table td {
    padding: 3px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-assumptions {
    font-size: 10px;
    color: #999;
    padding: 4px 0;
    line-height: 1.3;
    border-top: 1px dashed #eee;
    margin-top: 4px;
}
.sidebar-action-link {
    display: block;
    padding: 8px 0 4px;
    font-size: 12px;
    color: #1976d2;
    cursor: pointer;
    text-align: center;
    border-top: 1px solid #e8e8e8;
    margin-top: 6px;
}
.sidebar-action-link:hover {
    color: #0d47a1;
    text-decoration: underline;
}

/* Opportunity dimension tag */
.opp-dim-tag {
    display: inline-block;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 2px;
}

/* Mini dimension bars in opportunity rows */
.opp-dims {
    display: flex;
    gap: 2px;
    padding: 3px 0 1px;
    align-items: center;
}
.opp-dim-bar {
    height: 4px;
    border-radius: 2px;
    min-width: 3px;
    max-width: 60px;
    opacity: 0.85;
    transition: opacity 0.15s;
    cursor: default;
}
.opp-dim-bar:hover {
    opacity: 1;
    height: 6px;
}
.opp-dominant-tag {
    text-align: center;
    font-size: 11px;
    padding: 3px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
}

/* === LEGEND === */
.legend {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    font-size: 12px;
    line-height: 1.6;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-note {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* === GLOSSARY TOOLTIPS === */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    position: relative;
    margin-left: 3px;
    vertical-align: middle;
    flex-shrink: 0;
}
.info-tip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 220px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    line-height: 1.4;
    text-align: left;
}
.info-tip:hover::after {
    opacity: 1;
}
/* Modifier for tooltips near right edge */
.info-tip--left::after {
    left: auto;
    right: 0;
    transform: none;
}
/* Modifier for tooltips near top edge */
.info-tip--below::after {
    bottom: auto;
    top: calc(100% + 6px);
}

/* Help glossary section */
.help-glossary {
    display: grid;
    gap: 0;
}
.help-glossary-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.help-glossary-item:nth-child(odd) {
    background: #fafafa;
}
.help-glossary-item dt {
    font-weight: 600;
    font-size: 13px;
    color: #1565c0;
    margin-bottom: 2px;
}
.help-glossary-item dd {
    font-size: 12px;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

/* === TOOL BUTTONS (Ranking, Barrios) === */
.layer-separator {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 2px;
    align-self: center;
}

.tool-btn {
    padding: 5px 10px;
    background: #f8f0ff;
    border: 1px solid #c9a0dc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #7b2d8e;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: #7b2d8e;
    color: white;
    border-color: #7b2d8e;
}

/* === SIDE PANELS (Ranking, Barrios) === */
.side-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 380px;
    height: 100%;
    background: white;
    z-index: 1002;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.side-panel.hidden {
    transform: translateX(-100%);
    pointer-events: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 16px;
    color: #333;
    margin: 0;
}

.panel-close {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
}

.panel-close:hover {
    background: #f0f0f0;
}

/* Filters */
.panel-filters {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.filter-row {
    margin-bottom: 8px;
    font-size: 12px;
    color: #555;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-row label {
    display: block;
    margin-bottom: 3px;
}

.filter-row select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.filter-row input[type="range"] {
    width: 100%;
    margin-top: 2px;
}

.filter-checkbox {
    display: flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.filter-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

.dev-badge {
    display: inline-block;
    background: #f39c12;
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
}
.safety-badge-inline {
    display: inline-block;
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
}
.opp-dev {
    opacity: 0.75;
    border-left: 3px solid #f39c12;
}

/* Ranking list */
.panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    gap: 10px;
    transition: background 0.1s;
}

.ranking-item:hover {
    background: #f8f8ff;
}

.ranking-pos {
    width: 24px;
    font-size: 13px;
    font-weight: 700;
    color: #999;
    text-align: center;
    flex-shrink: 0;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-barrio {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-meta {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-rent {
    font-size: 11px;
    color: #2166ac;
    font-weight: 600;
    margin-top: 1px;
}

.ranking-revenue {
    font-size: 11px;
    font-weight: 600;
    margin-top: 1px;
}

.ranking-score {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.ranking-empty {
    padding: 40px 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Barrios table */
.panel-table-wrap {
    flex: 1;
    overflow-y: auto;
}

#barrios-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#barrios-table th {
    position: sticky;
    top: 0;
    background: #f8f8f8;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

#barrios-table th:hover {
    background: #eee;
}

#barrios-table th.sort-asc::after {
    content: ' ▲';
    font-size: 9px;
}

#barrios-table th.sort-desc::after {
    content: ' ▼';
    font-size: 9px;
}

#barrios-table td {
    padding: 6px;
    border-bottom: 1px solid #f5f5f5;
}

.barrio-row {
    cursor: pointer;
    transition: background 0.1s;
}

.barrio-row:hover {
    background: #f8f8ff;
}

.barrio-name {
    font-weight: 500;
    color: #333;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
    font-weight: 600;
    font-size: 11px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    min-width: 28px;
    text-align: center;
}

/* === OPORTUNIDADES PANEL === */
.tool-btn-green {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #2e7d32;
}

.tool-btn-green:hover {
    background: #2e7d32;
    color: white;
    border-color: #2e7d32;
}

.panel-count {
    font-size: 11px;
    color: #888;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
    margin-right: 8px;
}

.filter-row-inline {
    display: flex;
    gap: 8px;
}

.filter-half {
    flex: 1;
}

.filter-half input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

/* Opp-panel tabs (Alquiler / Venta toggle) */
.opp-tabs {
    display: flex;
    gap: 0;
    padding: 0 12px;
    border-bottom: 1px solid #e0e0e0;
}
.opp-tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.opp-tab:hover {
    color: #555;
}
.opp-tab.active {
    color: #2e7d32;
    border-bottom-color: #2e7d32;
}
.opp-desc {
    font-size: 11px;
    color: #777;
    margin-top: 2px;
}

.opp-rating {
    font-size: 11px;
    color: #666;
    margin-top: 1px;
}

.opp-score {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 13px;
}

/* === RESIDENCIAL PANEL === */
.tool-btn-orange {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
    font-weight: 600;
}

.tool-btn-orange:hover {
    background: #e65100;
    color: white;
    border-color: #e65100;
}

.res-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

.res-stat-box {
    text-align: center;
    padding: 8px 4px;
    background: #f8f8f8;
    border-radius: 6px;
}

.res-stat-num {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.res-stat-label {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
    text-transform: uppercase;
}

/* === BRANDS PANEL === */
.tool-btn-blue {
    background: #e3f2fd;
    border-color: #42a5f5;
    color: #1565c0;
    font-weight: 600;
}

.tool-btn-blue:hover {
    background: #1565c0;
    color: white;
    border-color: #1565c0;
}

.brand-info {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

.brand-content {
    flex: 1 1 0%;
    overflow-y: auto;
    min-height: 150px;
}

.brand-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12px;
    color: #555;
}

.brand-stat-row strong {
    color: #333;
}

.brand-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.brand-tab {
    flex: 1;
    padding: 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    transition: all 0.15s;
}

.brand-tab:hover {
    color: #555;
}

.brand-tab.active {
    color: #1565c0;
    border-bottom-color: #1565c0;
}

.brand-barrio-row {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    font-size: 12px;
    border-bottom: 1px solid #f5f5f5;
    gap: 8px;
}

.brand-barrio-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-barrio-dist {
    color: #888;
    font-size: 11px;
    white-space: nowrap;
}

/* === DESARROLLADORES MODE === */
.tool-btn-steel {
    background: #eceff1;
    border-color: #78909c;
    color: #37474f;
    font-weight: 600;
}

.tool-btn-steel:hover {
    background: #37474f;
    color: white;
    border-color: #37474f;
}

.tool-btn-purple {
    background: #f3e5f5;
    border-color: #9c27b0;
    color: #6a1b9a;
    font-weight: 600;
}

.tool-btn-purple:hover {
    background: #7b1fa2;
    color: white;
    border-color: #7b1fa2;
}

#dev-color-control {
    display: inline-flex;
    align-items: center;
}

#dev-color-control select {
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.ranking-distrito {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    color: white;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.ranking-buildable {
    font-size: 11px;
    color: #08519c;
    font-weight: 600;
    margin-top: 1px;
}

.catalogado-badge {
    display: inline-block;
    background: #6a1b9a;
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ============================
   HELP OVERLAY
   ============================ */

.help-btn {
    position: fixed;
    bottom: 90px;
    right: 28px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2c3e50;
    color: #fff;
    border: none;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: background 0.15s;
    line-height: 40px;
    text-align: center;
    padding: 0;
}
.help-btn:hover { background: #4a90d9; }

.help-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000;
    background: rgba(255,255,255,0.98);
    display: flex;
    overflow: hidden;
}
.help-overlay.hidden { display: none; }

.help-close {
    position: fixed;
    top: 14px;
    right: 22px;
    z-index: 2001;
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 50%;
}
.help-close:hover { background: #eee; color: #333; }

.help-nav {
    width: 200px;
    background: #f7f8fa;
    border-right: 1px solid #e8e8e8;
    padding: 20px 0;
    overflow-y: auto;
    flex-shrink: 0;
}
.help-nav-title {
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
    padding: 8px 20px 16px;
}
.help-nav a {
    display: block;
    padding: 7px 20px;
    color: #666;
    text-decoration: none;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.1s;
}
.help-nav a:hover { background: #eee; color: #333; }
.help-nav a.active {
    color: #2c3e50;
    font-weight: 600;
    border-left-color: #4a90d9;
    background: #e8f0fe;
}

.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px 48px;
    max-width: 900px;
}
.help-content h1 { font-size: 28px; color: #2c3e50; margin: 0 0 4px; }
.help-content h2 { font-size: 20px; color: #2c3e50; margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 2px solid #e8e8e8; }
.help-content h3 { font-size: 15px; color: #34495e; margin: 16px 0 8px; }
.help-content p { font-size: 14px; color: #444; line-height: 1.6; margin: 8px 0; }
.help-content ul, .help-content ol { font-size: 14px; color: #444; line-height: 1.7; padding-left: 24px; }
.help-subtitle { color: #888 !important; font-size: 15px !important; margin-bottom: 16px !important; }

.help-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin: 20px 0;
}
.help-kpi {
    text-align: center;
    padding: 14px 8px;
    background: #f0f4f8;
    border-radius: 8px;
}
.help-kpi-val { font-size: 22px; font-weight: 700; color: #2c3e50; }
.help-kpi-lbl { font-size: 11px; color: #888; text-transform: uppercase; margin-top: 2px; }

.help-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 10px 0;
    border-left: 4px solid #4a90d9;
}
.help-card h3 { margin: 0 0 6px; font-size: 14px; }
.help-card p { margin: 4px 0; font-size: 13px; }
.help-card-warn { border-left-color: #e67e22; background: #fef9f0; }

.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 12px 0;
}
.help-table th {
    background: #f0f0f0;
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    font-size: 12px;
}
.help-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
}
.help-table-compact td, .help-table-compact th { padding: 4px 8px; }

.help-swatch {
    display: inline-block;
    width: 20px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
}

.help-code {
    display: block;
    background: #2c3e50;
    color: #7fdbca;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
    margin: 8px 0;
    overflow-x: auto;
}

.help-note {
    font-size: 12px !important;
    color: #888 !important;
    font-style: italic;
}

/* ============================
   ANALYSIS DASHBOARD
   ============================ */

.analysis-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2;
    background: #f0f2f5;
    overflow-y: auto;
    padding: 70px 24px 24px;
}
.analysis-container.hidden { display: none; }

.analysis-header {
    text-align: center;
    margin-bottom: 20px;
}
.analysis-header h1 {
    font-size: 26px;
    color: #2c3e50;
    margin: 0 0 4px;
}
.analysis-subtitle {
    color: #888;
    font-size: 14px;
    margin: 0;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.analysis-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 20px;
}
.analysis-card.full-width, .analysis-card.a-card-full { grid-column: 1 / -1; }
.analysis-card h2 {
    font-size: 15px;
    color: #2c3e50;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.a-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}
.a-kpi {
    text-align: center;
    padding: 14px 8px;
    background: #f7f8fa;
    border-radius: 8px;
}
.a-kpi-val { font-size: 22px; font-weight: 700; color: #2c3e50; }
.a-kpi-lbl { font-size: 10px; color: #999; text-transform: uppercase; margin-top: 2px; letter-spacing: 0.3px; }

.a-chart-wrap { position: relative; height: 300px; }
.a-chart-wrap canvas { width: 100% !important; }

.a-table-wrap { max-height: 400px; overflow-y: auto; }
.a-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.a-table th {
    background: #f7f8fa;
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    cursor: pointer;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.a-table th:hover { background: #eef1f5; }
.a-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #f0f0f0;
}
.a-table tr:hover td { background: #f7f9fc; }

.a-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
}

.a-comparator-controls {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.a-comparator-controls select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 12px;
    min-width: 140px;
}
.a-comparator-controls button {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid #4a90d9;
    background: #4a90d9;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}
.a-comparator-controls button:hover { background: #357abd; }

.a-barrio-name { font-weight: 600; white-space: nowrap; }

.a-btn {
    padding: 6px 16px;
    border-radius: 4px;
    border: 1px solid #4a90d9;
    background: #4a90d9;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}
.a-btn:hover { background: #357abd; }

.a-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
.a-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }

/* === PORTFOLIO === */
.tool-btn-zone { background: #e3f2fd; border-color: #42a5f5; color: #1565c0; }
.tool-btn-zone:hover { background: #1565c0; color: white; border-color: #1565c0; }
.tool-btn-zone-active { background: #1565c0 !important; color: white !important; border-color: #0d47a1 !important; }
.tool-btn-zone-active:hover { background: #0d47a1 !important; }

.tool-btn-teal { background: #e0f7fa; border-color: #26c6da; color: #00838f; }
.tool-btn-teal:hover { background: #00838f; color: white; border-color: #00838f; }
.portfolio-badge {
    display: none;
    background: #00838f;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.portfolio-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1100;
    background: #f0f2f5;
    overflow-y: auto;
    padding: 24px;
}
.portfolio-container.hidden { display: none; }

.portfolio-header {
    position: sticky;
    top: 0;
    background: #f0f2f5;
    padding: 16px 0 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 16px;
}
.portfolio-header h1 {
    font-size: 22px;
    color: #2c3e50;
    font-weight: 700;
}
.portfolio-header span {
    font-size: 13px;
    color: #999;
}
.portfolio-back-btn {
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}
.portfolio-back-btn:hover { background: #f0f0f0; }

.portfolio-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 16px;
    position: sticky;
    top: 58px;
    background: #f0f2f5;
    z-index: 3;
}
.ptab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    transition: all 0.15s;
}
.ptab:hover { color: #00838f; }
.ptab.active { color: #00838f; border-bottom-color: #00838f; }

.portfolio-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}
.portfolio-empty-icon { font-size: 48px; margin-bottom: 16px; }
.portfolio-empty h2 { font-size: 18px; color: #666; margin-bottom: 8px; }
.portfolio-empty p { font-size: 14px; line-height: 1.5; }
.ptab-switch-btn { margin-top: 16px; padding: 8px 16px; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }

/* ── Portfolio Summary / Dashboard ─────────────────────────────── */
.psum-wrap { padding: 20px 24px; max-width: 1100px; margin: 0 auto; }
.psum-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.psum-kpi { background: #fff; border: 1px solid #e8ecf0; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.psum-kpi-val { font-size: 32px; font-weight: 800; color: #1a2634; line-height: 1.1; }
.psum-kpi-label { font-size: 12px; font-weight: 600; color: #7f8c8d; text-transform: uppercase; letter-spacing: 0.5px; margin: 6px 0 4px; }
.psum-kpi-sub { font-size: 12px; color: #999; }

.psum-body { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.psum-card { background: #fff; border: 1px solid #e8ecf0; border-radius: 10px; padding: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.psum-card-wide { grid-column: 1 / -1; }
.psum-card-title { font-size: 13px; font-weight: 700; color: #1a2634; margin-bottom: 14px; }

.psum-bar-list, .psum-rating-list { display: flex; flex-direction: column; gap: 8px; }
.psum-bar-row { display: grid; grid-template-columns: 110px 1fr 30px; align-items: center; gap: 8px; }
.psum-bar-label { font-size: 12px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psum-bar-track { height: 8px; background: #f0f4f8; border-radius: 4px; overflow: hidden; }
.psum-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s; }
.psum-bar-val { font-size: 12px; font-weight: 700; color: #555; text-align: right; }

.psum-rating-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #444; padding: 3px 0; border-bottom: 1px solid #f5f5f5; }
.psum-rating-row:last-child { border-bottom: none; }
.psum-rating-note { font-size: 11px; color: #27ae60; margin-top: 10px; font-weight: 600; }

.psum-score-bars { display: flex; flex-direction: column; gap: 8px; }
.psum-score-row { display: grid; grid-template-columns: 100px 1fr 36px 100px; align-items: center; gap: 8px; }
.psum-score-barrio { font-size: 12px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psum-score-track { height: 10px; background: #f0f4f8; border-radius: 5px; overflow: hidden; }
.psum-score-fill { height: 100%; border-radius: 5px; transition: width 0.4s; }
.psum-score-num { font-size: 13px; font-weight: 800; text-align: center; }
.psum-score-price { font-size: 11px; color: #888; text-align: right; }

.psum-actions { display: flex; gap: 12px; justify-content: center; padding-top: 8px; }
.psum-action-btn { padding: 10px 20px; border: 1px solid #e0e6ed; border-radius: 8px; background: #fff; color: #1a2634; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.psum-action-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 768px) {
    .psum-body { grid-template-columns: 1fr; }
    .psum-card-wide { grid-column: 1; }
    .psum-score-row { grid-template-columns: 80px 1fr 30px; }
    .psum-score-price { display: none; }
}

.portfolio-actions-bar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0;
    gap: 12px;
    align-items: center;
}
.portfolio-compare-btn {
    padding: 8px 16px;
    background: #00838f;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}
.portfolio-compare-btn:hover { background: #006064; }
.portfolio-compare-hint { font-size: 12px; color: #999; }

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
    max-width: 1400px;
}

/* Portfolio Cards */
.portfolio-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.portfolio-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.portfolio-card.selected { box-shadow: 0 0 0 2px #00838f, 0 2px 8px rgba(0,0,0,0.15); }
.portfolio-card.editing { box-shadow: 0 0 0 2px #f39c12; }

.pcard-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
}
.pcard-checkbox { display: flex; align-items: center; }
.pcard-checkbox input { cursor: pointer; width: 16px; height: 16px; }
.pcard-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-alquiler { background: #e8f5e9; color: #2e7d32; }
.badge-venta { background: #fce4ec; color: #c62828; }
.pcard-barrio { font-size: 14px; font-weight: 600; color: #2c3e50; flex: 1; }
.pcard-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 13px;
}

.pcard-body { padding: 4px 14px 10px; }
.pcard-price { font-size: 16px; font-weight: 700; color: #2c3e50; }
.pcard-edited { font-size: 12px; }
.pcard-meta { font-size: 12px; color: #888; margin-top: 2px; }
.pcard-address { font-size: 12px; color: #555; margin-top: 4px; }
.pcard-notes { font-size: 11px; color: #00838f; margin-top: 4px; font-style: italic; }
.pcard-date { font-size: 10px; color: #bbb; margin-top: 4px; }

.pcard-actions {
    display: flex;
    border-top: 1px solid #f0f0f0;
    padding: 0;
}
.pcard-btn {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    transition: all 0.15s;
}
.pcard-btn:hover { background: #f0f0f0; }
.pcard-btn-edit:hover { color: #f39c12; }
.pcard-btn-analyze:hover { color: #00838f; }
.pcard-btn-locate:hover { color: #3498db; }
.pcard-btn-delete:hover { color: #e74c3c; }

/* Edit form */
.pcard-edit-title {
    padding: 12px 14px 4px;
    font-weight: 600;
    color: #f39c12;
    font-size: 13px;
}
.pcard-edit-form {
    padding: 8px 14px;
}
.pcard-edit-form label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
}
.pcard-edit-form input, .pcard-edit-form textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 2px;
}
.pcard-edit-form textarea { resize: vertical; font-family: inherit; }
.pcard-edit-row { display: flex; gap: 8px; }
.pcard-edit-row label { flex: 1; }
.pcard-edit-actions {
    display: flex;
    gap: 8px;
    padding: 8px 14px 14px;
}

/* Save button in sidebar */
.save-portfolio-btn {
    flex: 1;
    padding: 10px;
    background: #00838f;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
}
.save-portfolio-btn:hover { background: #006064; }
.save-portfolio-btn.saved {
    background: #e0e0e0;
    color: #666;
    cursor: default;
}

/* PDF download button */
.pdf-download-btn {
    padding: 10px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
    white-space: nowrap;
}
.pdf-download-btn:hover { background: #2980b9; }

/* Barrios table PDF mini-button */
.barrio-pdf-btn {
    padding: 2px 6px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.15s;
}
.barrio-pdf-btn:hover { background: #e3f2fd; border-color: #3498db; }

/* CMA - Comparative Market Analysis */
.cma-section { margin-top: 12px; }
.cma-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 8px 0; font-size: 12px; }
.cma-stat { display: flex; justify-content: space-between; padding: 3px 0; }
.cma-price-bar { padding: 8px 0 4px; }
.cma-price-track { position: relative; height: 8px; background: #e0e0e0; border-radius: 4px; margin-bottom: 4px; }
.cma-price-marker { position: absolute; top: -3px; width: 14px; height: 14px; background: #e74c3c; border: 2px solid white; border-radius: 50%; transform: translateX(-50%); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.cma-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 8px; }
.cma-table th { background: #f5f5f5; padding: 5px 6px; text-align: left; font-weight: 600; border-bottom: 1px solid #ddd; }
.cma-table td { padding: 4px 6px; border-bottom: 1px solid #eee; }
.cma-comp-row:hover { background: #f0f7ff; }

/* Sidebar listing action buttons (edit/hide) */
.sidebar-listing-actions {
    display: flex;
    gap: 8px;
    padding: 4px 0 8px;
}
.sidebar-action-btn {
    flex: 1;
    padding: 7px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f8f8;
    cursor: pointer;
    font-size: 12px;
    color: #555;
    transition: all 0.15s;
    text-align: center;
}
.sidebar-action-btn:hover { background: #eee; border-color: #ccc; }
.sidebar-action-edit { color: #00838f; border-color: #b2ebf2; background: #e0f7fa; }
.sidebar-action-edit:hover { background: #b2ebf2; }
.sidebar-action-hide { color: #c62828; border-color: #ffcdd2; background: #fce4ec; }
.sidebar-action-hide:hover { background: #ffcdd2; }

/* Sidebar inline edit form */
.sidebar-edit-form {
    padding: 8px 0;
    border-top: 1px solid #eee;
    margin-top: 4px;
}
.sidebar-edit-form label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
}
.sidebar-edit-form input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 2px;
    box-sizing: border-box;
}
.sidebar-edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.sidebar-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Portfolio card link to ZonaProp */
.pcard-link {
    display: inline-block;
    color: #3498db;
    font-size: 11px;
    text-decoration: none;
    padding: 2px 0;
}
.pcard-link:hover { text-decoration: underline; }

/* Quick-save star in opportunities */
.opp-save-icon {
    position: absolute;
    top: 8px;
    right: 46px;
    cursor: pointer;
    font-size: 16px;
    color: #ccc;
    transition: color 0.15s;
    z-index: 1;
}
.opp-save-icon:hover { color: #00838f; }
.opp-save-icon.saved { color: #00838f; }

/* Deal Analyzer */
.deal-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.deal-selector label { font-weight: 600; color: #2c3e50; font-size: 14px; white-space: nowrap; }
.deal-selector select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.deal-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 16px;
    max-width: 1400px;
}

.deal-form {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 16px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}
.deal-form-section { margin-bottom: 16px; }
.deal-form-section h3 {
    font-size: 13px;
    color: #2c3e50;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f0f0f0;
}
.deal-form label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
}
.deal-form input[type="number"], .deal-form select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 2px;
}
.deal-form input[type="range"] { width: 100%; margin-top: 4px; }
.deal-form-row { display: flex; gap: 8px; }
.deal-form-row label { flex: 1; }

.deal-results { display: flex; flex-direction: column; gap: 14px; }

.deal-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.deal-kpi {
    text-align: center;
    padding: 14px 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.deal-kpi-val { font-size: 20px; font-weight: 700; color: #2c3e50; }
.deal-kpi-lbl { font-size: 10px; color: #999; text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

.deal-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 16px;
}
.deal-card h3 {
    font-size: 14px;
    color: #2c3e50;
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #f0f0f0;
}
.deal-chart-wrap { position: relative; height: 280px; }

.deal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.deal-table th { background: #f7f8fa; padding: 6px 8px; text-align: left; font-weight: 600; border-bottom: 2px solid #e0e0e0; }
.deal-table td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; }
.deal-table tr:hover td { background: #f7f9fc; }
.deal-table-total td { border-top: 2px solid #333; background: #f7f8fa; }
.deal-table-profit td { background: #f0f8f0; }

/* Break-even bar */
.deal-be-bar {
    position: relative;
    height: 20px;
    background: #eee;
    border-radius: 4px;
    overflow: visible;
    margin-top: 8px;
}
.deal-be-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.deal-be-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 28px;
    background: #333;
    border-radius: 2px;
    transform: translateX(-50%);
}

/* Self-pay */
.deal-selfpay-result {
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
}
.deal-selfpay-result.positive { background: #e8f5e9; color: #2e7d32; }
.deal-selfpay-result.negative { background: #fce4ec; color: #c62828; }
.deal-selfpay-negative { padding: 12px; background: #fff3e0; color: #e65100; border-radius: 8px; font-size: 13px; }

/* Cost rate hints */
.deal-rate-hint { font-size: 10px; color: #999; font-weight: 400; }

/* Ramp-up table */
.deal-rampup-table td { font-size: 11px; }
.deal-rampup-payback {
    background: #e8f5e9 !important;
    border-left: 3px solid #1a9850;
}

/* Scenario legend */
.deal-scenario-legend {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
}

/* Developer timeline bar */
.deal-timeline-bar {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 4px;
}
.deal-timeline-phase {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    min-width: 40px;
}
.deal-timeline-phase span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* Comparison */
.compare-cards {
    display: flex;
    gap: 14px;
    overflow-x: auto;
}
.compare-card {
    flex: 1;
    min-width: 220px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
}
.compare-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
}
.compare-card-body { padding: 4px 14px 14px; }
.compare-metric {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid #f5f5f5;
}
.compare-metric span { color: #888; }
.compare-metric strong { color: #2c3e50; }
.compare-notes { font-size: 11px; color: #00838f; font-style: italic; margin-top: 6px; }

.compare-table td { text-align: center; }
.compare-winner { background: #e8f5e9 !important; font-weight: 700; color: #2e7d32; }

/* === MODERATOR PANEL === */
.tool-btn-mod {
    background: #fff8e1;
    border-color: #ffc107;
    color: #f57f17;
    font-weight: 600;
}
.tool-btn-mod:hover {
    background: #f57f17;
    color: white;
    border-color: #f57f17;
}

.mod-badge-count {
    display: none;
    background: #f57f17;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.mod-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1100;
    background: #f0f2f5;
    overflow-y: auto;
    padding: 24px;
}
.mod-container.hidden { display: none; }

.mod-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.mod-header h1 {
    font-size: 22px;
    color: #2c3e50;
    font-weight: 700;
    flex: 1;
}

.mod-logout-btn {
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #888;
}
.mod-logout-btn:hover { background: #f0f0f0; color: #555; }

/* Login */
.mod-login {
    max-width: 400px;
    margin: 60px auto;
    text-align: center;
    background: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.mod-login p {
    color: #666;
    font-size: 14px;
    margin-bottom: 16px;
}
.mod-login-row {
    display: flex;
    gap: 8px;
}
.mod-login-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.mod-login-row button {
    padding: 10px 20px;
    background: #f57f17;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}
.mod-login-row button:hover { background: #e65100; }

/* Tabs */
.mod-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 16px;
}
.mod-tab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    transition: all 0.15s;
}
.mod-tab:hover { color: #555; }
.mod-tab.active { color: #f57f17; border-bottom-color: #f57f17; }

/* Edit list */
.mod-list {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mod-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 14px;
}

/* Edit card */
.mod-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 16px;
}

.mod-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.mod-badge-alquiler {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: #e8f5e9;
    color: #2e7d32;
}
.mod-badge-venta {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: #fce4ec;
    color: #c62828;
}

.mod-card-url {
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mod-card-fields {
    margin-bottom: 8px;
}

.mod-field {
    font-size: 13px;
    color: #333;
    padding: 3px 0;
}
.mod-field-label {
    color: #888;
}
.mod-field-hide {
    color: #c62828;
    font-weight: 600;
}

.mod-card-user-note {
    font-size: 12px;
    color: #555;
    font-style: italic;
    padding: 4px 0;
    margin-bottom: 4px;
}

.mod-card-meta {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 8px;
}

.mod-card-note {
    margin-bottom: 8px;
}
.mod-card-note input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.mod-card-actions {
    display: flex;
    gap: 8px;
}

.mod-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.15s;
}
.mod-btn:disabled { opacity: 0.5; cursor: default; }
.mod-btn-approve { background: #e8f5e9; color: #2e7d32; }
.mod-btn-approve:hover:not(:disabled) { background: #c8e6c9; }
.mod-btn-reject { background: #fce4ec; color: #c62828; }
.mod-btn-reject:hover:not(:disabled) { background: #ffcdd2; }
.mod-btn-delete { background: #f5f5f5; color: #888; }
.mod-btn-delete:hover:not(:disabled) { background: #e0e0e0; color: #555; }

.mod-review-note {
    font-size: 12px;
    color: #555;
    padding: 4px 0;
    margin-bottom: 4px;
}
.mod-reviewed-at {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 4px;
}

/* Suggest form styles (sidebar) */
.sidebar-suggest-form {
    padding: 8px 0;
    border-top: 1px solid #eee;
    margin-top: 4px;
}
.sidebar-suggest-form label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
}
.sidebar-suggest-form input, .sidebar-suggest-form textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 2px;
    box-sizing: border-box;
}
.sidebar-suggest-form textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 40px;
}
.sidebar-suggest-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.sidebar-action-suggest {
    color: #f57f17;
    border-color: #ffecb3;
    background: #fff8e1;
}
.sidebar-action-suggest:hover { background: #ffecb3; }

.sidebar-suggest-status {
    font-size: 12px;
    padding: 6px 0;
    font-weight: 500;
}

/* Shared edit indicator in sidebar */
.shared-edit-indicator {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ─── Pending edit banner (crowd-sourced validation) ─────────────── */
.pending-edit-banner {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 12px;
}
.pending-edit-text {
    color: #333;
    margin-bottom: 6px;
    line-height: 1.4;
}
.pending-edit-note {
    color: #888;
    font-style: italic;
    font-size: 11px;
    margin-top: 3px;
}
.pending-edit-votes {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pending-edit-count {
    font-size: 11px;
    color: #888;
    flex: 1;
}
.pending-vote-btn {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}
.pending-vote-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.pending-vote-yes {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}
.pending-vote-yes:hover:not(:disabled) { background: #c8e6c9; }
.pending-vote-no {
    background: #fce4ec;
    color: #c62828;
    border-color: #ef9a9a;
}
.pending-vote-no:hover:not(:disabled) { background: #ffcdd2; }
.pending-vote-btn.voted {
    opacity: 0.7;
    font-weight: 700;
}
.pending-edit-resolved {
    font-weight: 600;
    font-size: 12px;
    padding: 4px 0;
}

/* Moderator: vote counts and auto badge */
.mod-votes {
    font-size: 12px;
    color: #666;
    padding: 4px 0;
    margin-bottom: 4px;
}
.mod-auto-badge {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    letter-spacing: 0.5px;
}

/* === ONBOARDING MODAL === */
/* ─── Onboarding tip (post-landing guided hint) ─── */
.onboarding-tip {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    background: #1a2634;
    color: #fff;
    border-radius: 12px;
    padding: 14px 20px 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    max-width: 380px;
    width: 90%;
    animation: tipSlideUp 0.4s ease;
}
@keyframes tipSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.onboarding-tip-icon { font-size: 22px; flex-shrink: 0; }
.onboarding-tip-text { font-size: 13px; line-height: 1.4; flex: 1; }
.onboarding-tip-text strong { display: block; margin-bottom: 2px; font-size: 14px; }
.onboarding-tip-text span { color: #aabdcc; }
.onboarding-tip-close {
    position: absolute;
    top: 6px; right: 8px;
    background: none; border: none; color: #aabdcc;
    font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 4px;
}
.onboarding-tip-close:hover { color: #fff; }

/* Legacy .onboarding-overlay kept for backward compat (no longer shown) */
.onboarding-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
.onboarding-modal {
    background: white;
    border-radius: 16px;
    padding: 36px 32px 28px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.onboarding-modal h2 {
    margin: 0 0 8px;
    font-size: 24px;
    color: #1a1a2e;
}
.onboarding-subtitle {
    margin: 0 0 24px;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}
.onboarding-steps {
    text-align: left;
    margin: 0 0 24px;
}
.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.onboarding-step:last-child {
    border-bottom: none;
}
.onboarding-icon {
    font-size: 28px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}
.onboarding-step strong {
    display: block;
    font-size: 14px;
    color: #1a1a2e;
    margin-bottom: 2px;
}
.onboarding-step p {
    margin: 0;
    font-size: 12px;
    color: #888;
    line-height: 1.3;
}
.onboarding-cta {
    display: block;
    width: 100%;
    padding: 14px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    transition: background 0.2s;
}
.onboarding-cta:hover {
    background: #219a52;
}
.onboarding-link {
    display: inline-block;
    font-size: 13px;
    color: #4a90d9;
    text-decoration: none;
}
.onboarding-link:hover {
    text-decoration: underline;
}

/* === WELCOME ONBOARDING (post-register) === */
.welcome-onboarding-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10500;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.welcome-onboarding-card {
    background: #fff;
    border-radius: 18px;
    padding: 36px 32px 28px;
    max-width: 540px;
    width: 92%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}
.welcome-onboarding-header { text-align: center; margin-bottom: 28px; }
.welcome-onboarding-badge {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 16px;
}
.welcome-onboarding-title { font-size: 24px; font-weight: 800; color: #1a2634; margin: 0 0 8px; }
.welcome-onboarding-sub { font-size: 14px; color: #666; line-height: 1.5; margin: 0; }
.welcome-onboarding-steps { display: flex; flex-direction: column; gap: 0; margin-bottom: 28px; }
.welcome-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f4f8;
}
.welcome-step:last-child { border-bottom: none; }
.welcome-step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.welcome-step-body {}
.welcome-step-title { font-size: 14px; font-weight: 700; color: #1a2634; margin-bottom: 3px; }
.welcome-step-desc { font-size: 13px; color: #666; line-height: 1.4; }
.welcome-onboarding-footer { text-align: center; }
.welcome-onboarding-cta {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 12px;
    transition: background 0.2s;
}
.welcome-onboarding-cta:hover { background: #006064; }
.welcome-trial-note { font-size: 12px; color: #999; line-height: 1.4; }

/* === LANDING OVERLAY === */
.landing-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: landingFadeIn 0.4s ease;
}

@keyframes landingFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.landing-card {
    background: white;
    border-radius: 16px;
    max-width: 520px;
    width: 90%;
    padding: 40px 36px 32px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: landingSlideUp 0.5s ease;
}

@keyframes landingSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.landing-card h1 {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.landing-card .landing-tagline {
    color: #7f8c8d;
    font-size: 15px;
    margin-bottom: 28px;
}

.landing-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 28px;
}

.landing-stat {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px 18px;
    flex: 1;
    min-width: 0;
}

.landing-stat .stat-num {
    font-size: 22px;
    font-weight: 800;
    color: #2c3e50;
    line-height: 1.1;
}

.landing-stat .stat-label {
    font-size: 11px;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.landing-features {
    text-align: left;
    margin-bottom: 28px;
    padding: 0 8px;
}

.landing-features li {
    list-style: none;
    padding: 6px 0;
    font-size: 14px;
    color: #34495e;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.landing-features li::before {
    content: '';
    display: none;
}

.landing-feature-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.landing-cta {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-btn {
    padding: 12px 28px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.landing-btn-primary {
    background: #2c3e50;
    color: white;
}

.landing-btn-primary:hover {
    background: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44,62,80,0.3);
}

.landing-btn-wa {
    background: #25d366;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.landing-btn-wa:hover {
    background: #20b858;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,211,102,0.3);
}

.landing-badge {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.landing-story {
    background: #f8f9fa;
    border-left: 3px solid #2c3e50;
    border-radius: 0 8px 8px 0;
    padding: 14px 16px;
    margin-bottom: 24px;
    text-align: left;
}

.landing-story-quote {
    font-size: 13px;
    color: #34495e;
    line-height: 1.55;
    font-style: italic;
}

.landing-story-author {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 8px;
    font-style: normal;
}

.landing-skip {
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 12px;
    cursor: pointer;
    margin-top: 12px;
    text-decoration: underline;
    display: block;
    width: 100%;
    text-align: center;
}

.landing-skip:hover {
    color: #7f8c8d;
}

/* === WHATSAPP FLOATING BUTTON === */
/* Compact: top-right below the top-bar, fuera del camino del legend y zoom controls.
   Tamaño reducido de 56→42px para look "tool" en vez de "consumer chat widget". */
.wa-float {
    position: fixed;
    top: 64px;
    right: 16px;
    z-index: 2000;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #25d366;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    transition: all 0.2s;
    opacity: 0.85;
}

.wa-float:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(37,211,102,0.45);
    opacity: 1;
}

.wa-float svg {
    width: 22px;
    height: 22px;
    fill: white;
}

/* Tooltip repositioned to anchor near the new button location */
.wa-tooltip {
    top: 116px !important;
    right: 16px !important;
    bottom: auto !important;
    max-width: 240px !important;
}

.wa-tooltip {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 2000;
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    font-size: 13px;
    color: #333;
    max-width: 220px;
    animation: waTooltipIn 0.3s ease;
    cursor: pointer;
}

.wa-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

@keyframes waTooltipIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.wa-tooltip-close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #999;
}

/* === RESPONSIVE === */

/* Medium screens: stack top-bar vertically */
@media (max-width: 900px) {
    #top-bar {
        flex-wrap: wrap;
    }

    #search-bar {
        flex-basis: 100%;
    }

    #layer-controls {
        top: 90px;
    }

    #search-input {
        min-width: 140px;
    }
}

/* Small screens */
@media (max-width: 768px) {
    #mode-tabs {
        gap: 1px;
        padding: 2px;
    }

    .mode-tab {
        padding: 5px 8px;
        font-size: 11px;
    }

    #top-bar {
        flex-wrap: wrap;
        gap: 4px;
    }

    #search-bar {
        flex-basis: 100%;
    }

    #search-input {
        min-width: 0;
    }

    #search-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    #layer-controls {
        top: 84px;
        gap: 2px;
        padding: 3px;
    }

    .layer-btn {
        padding: 4px 7px;
        font-size: 10px;
    }

    .tool-btn {
        padding: 4px 7px;
        font-size: 10px;
    }

    #sidebar {
        width: 100%;
    }

    .side-panel {
        width: 100%;
    }

    .help-nav { display: none; }
    .help-content { padding: 20px 16px; }

    .analysis-container { padding: 64px 12px 12px; }
    .analysis-grid { grid-template-columns: 1fr; }
    .a-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .portfolio-container { padding: 12px; }
    .portfolio-grid { grid-template-columns: 1fr; }
    .deal-layout { grid-template-columns: 1fr; }
    .deal-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .compare-cards { flex-direction: column; }

    .landing-card { padding: 28px 20px 24px; }
    .landing-card h1 { font-size: 22px; }
    .landing-stats { flex-direction: column; gap: 8px; }
    .landing-stat { padding: 10px 14px; }

    /* Sidebar as bottom sheet on mobile */
    #sidebar {
        top: auto;
        bottom: 0;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
    #sidebar.collapsed {
        transform: translateY(100%);
    }
    #sidebar-close {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    /* Side panels as bottom sheets */
    .side-panel {
        top: auto;
        bottom: 0;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }

    /* Rubro selector inline */
    #rubro-select {
        font-size: 11px;
        padding: 4px 6px;
    }

    /* Tool buttons row wrap */
    #panel-controls {
        flex-wrap: wrap;
    }

    /* Barrios table scroll */
    .panel-table-wrap {
        font-size: 11px;
    }
    .panel-table-wrap th,
    .panel-table-wrap td {
        padding: 4px 3px;
    }

    /* PDF buttons smaller */
    .pdf-download-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Score number smaller */
    #score-number { font-size: 36px; }

    .wa-float { bottom: 16px; right: 16px; width: 48px; height: 48px; }
    .wa-float svg { width: 24px; height: 24px; }
    .wa-tooltip { bottom: 72px; right: 16px; }
    .help-btn { bottom: 74px; right: 20px; width: 36px; height: 36px; font-size: 17px; line-height: 36px; }
}

/* === COMPETITIVE INTELLIGENCE === */
/* Floating Simulator Card */
.sim-float {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    z-index: 1003;
    transition: opacity 0.2s, transform 0.2s;
}
.sim-float.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}
.sim-float-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1565c0;
    color: white;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    font-size: 13px;
}
.sim-float-header .panel-close {
    color: white;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
}
.sim-float-header .panel-close:hover { opacity: 1; }
.sim-float-body {
    padding: 12px 14px;
}
.sim-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}
.sim-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e3f2fd;
    color: #1565c0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.sim-step-content {
    flex: 1;
}
.sim-step-content label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
}
.sim-step-content select {
    width: 100%;
    font-size: 12px;
    padding: 4px 6px;
    margin-top: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.sim-step-content input[type="range"] {
    width: 100%;
    margin: 4px 0 0;
}
.sim-placing-banner {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    animation: sim-pulse-bg 1.5s ease-in-out infinite;
}
.sim-placing-banner.hidden { display: none; }
@keyframes sim-pulse-bg {
    0%, 100% { background: #fff3cd; }
    50% { background: #ffe082; }
}

.brand-tab-sim {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    font-weight: 600 !important;
}
.brand-tab-sim:hover {
    background: #c8e6c9 !important;
}

.btn-sim {
    width: 100%;
    padding: 10px 12px;
    background: #1565c0;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-sim:hover { background: #0d47a1; }

.btn-sim.active {
    background: #c62828;
}

.btn-sim.active:hover { background: #b71c1c; }

.sim-result-summary {
    padding: 8px 0;
    font-size: 12px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}

.sim-metric {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #f5f5f5;
}

.sim-metric strong { color: #1565c0; }
.sim-metric.negative strong { color: #c62828; }
.sim-metric.positive strong { color: #2e7d32; }

.sim-affected-store {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 11px;
    border-bottom: 1px solid #f5f5f5;
    gap: 8px;
}

.sim-affected-store .chain-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sim-affected-store .store-info { flex: 1; }
.sim-affected-store .store-impact {
    font-weight: 600;
    white-space: nowrap;
}
.sim-affected-store .store-impact.loss { color: #c62828; }

.territory-controls {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
}

.btn-territory {
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-territory.active {
    background: #1565c0;
    color: white;
    border-color: #1565c0;
}

.dashboard-metric-card {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.dashboard-metric-card .metric-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
}

.dashboard-metric-card .metric-value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.dashboard-metric-card .metric-sub {
    font-size: 11px;
    color: #666;
}

.chain-compare-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}

.chain-compare-table th {
    background: #f5f5f5;
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 1px solid #ddd;
}

.chain-compare-table th:hover { background: #e8e8e8; }

.chain-compare-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #f5f5f5;
}

.chain-compare-table tr:hover { background: #f9f9f9; }

/* Safety badges */
.safety-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    color: #fff;
    vertical-align: middle;
    margin-left: 2px;
}
.safety-badge.safe { background: #2e7d32; }
.safety-badge.moderate { background: #ef6c00; }
.safety-badge.risky { background: #c62828; }

/* Brand opportunity financial line */
.brand-opp-financial {
    font-size: 10px;
    color: #1565c0;
    font-weight: 500;
}

/* Expansion summary */
.expansion-summary {
    padding: 6px 12px 10px;
}
.expansion-totals {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.expansion-stat {
    flex: 1;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
}
.expansion-label {
    display: block;
    font-size: 9px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.expansion-value {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #333;
    margin-top: 2px;
}
.expansion-value.positive { color: #2e7d32; }
.expansion-opp {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    border-bottom: 1px solid #f0f0f0;
}
.expansion-chain {
    font-weight: 600;
    min-width: 70px;
}
.expansion-barrio {
    flex: 1;
    color: #555;
}
.expansion-metrics {
    color: #1565c0;
    font-size: 10px;
    white-space: nowrap;
}

@keyframes sim-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.sim-pulse-marker {
    animation: sim-pulse 1.5s ease-in-out infinite;
}

/* ── Auth / Login ──────────────────────────── */
.login-btn {
    background: #1a9850;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.login-btn:hover { background: #15803d; }

/* ─── Graveyard layer (avisos cerrados, datos exclusivos MapComercial) ─── */
.layer-btn-graveyard {
    background: #f3f4f6 !important;
    color: #4b5563 !important;
    border-color: #d1d5db !important;
}
.layer-btn-graveyard.active {
    background: #4b5563 !important;
    color: white !important;
    border-color: #1f2937 !important;
}
.layer-btn-graveyard:hover {
    background: #6b7280 !important;
    color: white !important;
}

.graveyard-cluster-wrap {
    background: transparent !important;
    border: none !important;
}
.graveyard-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(75,85,99,0.85);
    color: white;
    font-weight: 600;
    font-size: 11px;
    border: 2px solid rgba(31,41,55,0.7);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.graveyard-cluster-sm { width: 28px; height: 28px; font-size: 10px; }
.graveyard-cluster-md { width: 36px; height: 36px; font-size: 12px; }
.graveyard-cluster-lg { width: 44px; height: 44px; font-size: 14px; }

.graveyard-tooltip {
    background: #1f2937 !important;
    color: white !important;
    border: none !important;
    font-size: 12px;
}

/* ─── Lifecycle features (freshness, report-dead, absorption) ─── */

.lifecycle-freshness-slot {
    margin: 8px 0 4px;
    min-height: 0;
}

.lifecycle-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    cursor: help;
    user-select: none;
}

.lifecycle-badge.lifecycle-dead {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.sidebar-action-report {
    background: #fff7ed !important;
    color: #9a3412 !important;
    border: 1px solid #fed7aa !important;
}
.sidebar-action-report:hover {
    background: #9a3412 !important;
    color: white !important;
    border-color: #9a3412 !important;
}
.sidebar-action-report:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Barrio absorption block (#7 graveyard feature) */
.barrio-absorption {
    margin: 12px 0;
    padding: 10px 12px;
    background: linear-gradient(135deg, #fafaf9 0%, #f5f5f4 100%);
    border-left: 3px solid #6b7280;
    border-radius: 4px;
    font-size: 12px;
}
.barrio-absorption-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #1f2937;
}
.barrio-absorption-icon {
    font-size: 14px;
}
.barrio-absorption-tag {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.barrio-absorption-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: #4b5563;
}
.barrio-absorption-row strong {
    color: #1f2937;
}
.barrio-absorption-note {
    margin-top: 6px;
    font-size: 10px;
    color: #9ca3af;
    font-style: italic;
}

/* Topbar Alerts button — small bell with badge, just before Portafolio */
.topbar-alerts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #d97706;
    border: 1.5px solid #f59e0b;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    margin-right: 4px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}
.topbar-alerts-btn:hover {
    background: #f59e0b;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}
.topbar-alerts-icon { line-height: 1; pointer-events: none; }
.topbar-alerts-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
    border: 1.5px solid white;
}
.topbar-alerts-badge:empty {
    display: none !important;
}

/* Hide the legacy floating alerts button (now in top-bar) */
.alerts-btn {
    display: none !important;
}

/* Topbar Portafolio button — prominent, always visible */
.topbar-portfolio-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #00838f;
    border: 1.5px solid #26c6da;
    padding: 5px 12px 5px 10px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    position: relative;
    margin-right: 4px;
}
.topbar-portfolio-btn:hover {
    background: #00838f;
    color: white;
    border-color: #00838f;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,131,143,0.25);
}
.topbar-portfolio-icon { font-size: 14px; line-height: 1; }
.topbar-portfolio-label { line-height: 1; }
.topbar-portfolio-btn .portfolio-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
}
.topbar-portfolio-btn:hover .portfolio-badge {
    background: white;
    color: #ef4444;
}

#user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
}
#user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tier-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tier-free { background: #e2e8f0; color: #475569; }
.tier-pro { background: #1a9850; color: white; }
.tier-enterprise { background: #1a365d; color: white; }

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px;
    z-index: 1000;
    min-width: 160px;
}
.user-dropdown.show { display: block; }
.user-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    color: #334155;
}
.user-dropdown button:hover { background: #f1f5f9; }

/* ── Modals (auth + upgrade) ──────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
.modal-box {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
}
.modal-close:hover { color: #334155; }

/* Auth modal */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e2e8f0;
}
.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.auth-tab.active {
    color: #1a365d;
    border-bottom-color: #1a9850;
}
.auth-form input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}
.auth-form input:focus {
    outline: none;
    border-color: #1a9850;
    box-shadow: 0 0 0 3px rgba(26,152,80,0.1);
}
.auth-error {
    color: #dc2626;
    font-size: 13px;
    min-height: 18px;
    margin: 0 0 8px;
}
.auth-submit {
    display: block;
    width: 100%;
    padding: 12px;
    background: #1a365d;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.auth-submit:hover { background: #0f172a; }

.auth-link {
    display: block;
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }
.auth-hint { font-size: 13px; color: #64748b; margin-bottom: 12px; }
.auth-success { color: #16a34a; font-size: 13px; min-height: 18px; }

/* Admin panel */
.admin-box { max-width: 900px; width: 95%; max-height: 80vh; overflow-y: auto; }
.admin-stats { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-stat { padding: 8px 16px; background: #f1f5f9; border-radius: 6px; font-size: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { background: #1e293b; color: #fff; padding: 8px 10px; text-align: left; }
.admin-table td { padding: 6px 10px; border-bottom: 1px solid #e2e8f0; }
.admin-table tr:hover td { background: #f8fafc; }
.admin-table select { padding: 4px 8px; border-radius: 4px; border: 1px solid #cbd5e1; font-size: 12px; }

/* Upgrade modal */
.upgrade-box h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: #1a365d;
}
.upgrade-box p {
    margin: 0 0 20px;
    font-size: 14px;
    color: #64748b;
}
.upgrade-benefits {
    display: grid;
    gap: 8px;
    margin-bottom: 24px;
}
.upgrade-item {
    padding: 10px 14px;
    background: #f0fdf4;
    border-radius: 8px;
    font-size: 14px;
    color: #166534;
    font-weight: 500;
}
.upgrade-cta {
    display: block;
    text-align: center;
    padding: 14px;
    background: #1a9850;
    color: white;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s;
}
.upgrade-cta:hover { background: #15803d; }
.upgrade-cta-mp {
    background: #009ee3;
    margin-top: 8px;
}
.upgrade-cta-mp:hover { background: #007bb6; }
.upgrade-buttons { display: grid; gap: 0; }
.upgrade-price {
    text-align: center;
    margin: 0 0 16px;
}
.upgrade-price-amount {
    font-size: 36px;
    font-weight: 800;
    color: #1a365d;
}
.upgrade-price-period {
    font-size: 16px;
    color: #94a3b8;
}
.upgrade-note {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin: 12px 0 0 !important;
}

/* Sidebar auth gate CTA */
.sidebar-auth-cta {
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #f0fdf4, #e0f2fe);
    border-radius: 12px;
    margin: 12px 0;
}
.sidebar-auth-cta h3 {
    margin: 0 0 8px;
    color: #1a365d;
    font-size: 16px;
}
.sidebar-auth-cta p {
    margin: 0 0 16px;
    color: #64748b;
    font-size: 13px;
}
.sidebar-auth-cta button {
    background: #1a9850;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.sidebar-auth-cta button:hover { background: #15803d; }

/* Percentile badges */
.percentile-badges {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0 8px;
}
.percentile-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-left: 3px solid #ccc;
    background: #f8f9fa;
    border-radius: 0 6px 6px 0;
}
.percentile-value {
    font-weight: 700;
    font-size: 14px;
    min-width: 32px;
}
.percentile-label {
    font-size: 11px;
    color: #555;
    line-height: 1.3;
}

/* Trend sparkline inline */
.trend-indicator {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

/* Alerts button & badge */
.alerts-btn {
    position: fixed;
    top: 12px;
    right: 90px;
    z-index: 1000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e67e22;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.alerts-btn::before { content: '\01F514'; }
.alerts-btn:hover { background: #fff3e0; }
.alerts-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Alerts panel */
.alerts-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    width: 360px;
    max-height: calc(100vh - 80px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    z-index: 1100;
    overflow-y: auto;
    padding: 0;
}
.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 12px 12px 0 0;
}
.alerts-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1a365d;
}
.alerts-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
}
.alerts-section-title {
    padding: 10px 16px 4px;
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* Mode tag in alerts header (e.g. "Comercial", "Residencial") */
.alerts-mode-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
/* Empty state for modes with no alerts */
.alerts-empty {
    padding: 28px 20px;
    text-align: center;
    color: #6b7280;
}
.alerts-empty p {
    margin: 0 0 6px;
    font-size: 13px;
}
.alerts-empty-sub {
    color: #9ca3af !important;
    font-size: 11px !important;
}
.alert-card {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}
.alert-card:hover { background: #f8f9fa; }
.alert-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.alert-tag {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.alert-barrio {
    font-size: 11px;
    color: #888;
    font-weight: 600;
}
.alert-message {
    font-size: 13px;
    color: #333;
    line-height: 1.3;
}
.alert-detail {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* ─── Compare Tray ─────────────────────────────────────────────────── */
.compare-tray {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    background: #1a2634;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.35);
    padding: 10px 14px;
    min-width: 320px;
    max-width: 700px;
    transition: transform 0.25s ease;
}
.compare-tray.hidden { display: none; }
.compare-tray-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}
.compare-tray-label {
    font-size: 12px;
    font-weight: 700;
    color: #aac;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.compare-tray-item {
    position: relative;
    background: rgba(255,255,255,0.07);
    border-radius: 6px;
    padding: 6px 24px 6px 10px;
    min-width: 120px;
    max-width: 160px;
}
.compare-tray-barrio {
    font-size: 12px;
    font-weight: 600;
    color: #ecf0f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compare-tray-price {
    font-size: 11px;
    color: #aac;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compare-tray-remove {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #aac;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.compare-tray-remove:hover { color: #e74c3c; }
.compare-tray-hint {
    font-size: 11px;
    color: #667;
    white-space: nowrap;
}
.compare-tray-go {
    background: #00838f;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.compare-tray-go:hover { background: #006064; }
.compare-tray-go.disabled { background: #444; cursor: default; opacity: 0.6; }
.compare-tray-clear {
    background: none;
    border: none;
    color: #667;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.compare-tray-clear:hover { color: #e74c3c; }

/* ─── Compare Overlay ──────────────────────────────────────────────── */
.compare-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 3000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 12px;
    overflow-y: auto;
}
.compare-overlay.hidden { display: none; }
.compare-panel {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 960px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    overflow: hidden;
}
.compare-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a2634;
    color: #fff;
    padding: 14px 20px;
}
.compare-panel-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #ecf0f1;
}
.compare-panel-close {
    background: none;
    border: none;
    color: #aac;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.compare-panel-close:hover { color: #e74c3c; }
.compare-panel-body { padding: 20px; }

/* Column grid layout */
.compare-col-layout {
    display: flex;
    gap: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.compare-row-label-col {
    flex: 0 0 130px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
}
.compare-col-header-blank {
    height: 100px;
    border-bottom: 1px solid #e0e0e0;
}
.compare-metric-label {
    padding: 7px 10px;
    font-size: 11px;
    color: #666;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    min-height: 34px;
}
.compare-col {
    flex: 1;
    border-left: 1px solid #e0e0e0;
    min-width: 0;
}
.compare-col-header {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
    height: 100px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.compare-col-barrio {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compare-col-address {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compare-col-price {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}
.compare-col-score {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    align-self: flex-start;
}
.compare-metric-cell {
    padding: 7px 10px;
    font-size: 12px;
    color: #333;
    border-bottom: 1px solid #eee;
    min-height: 34px;
    display: flex;
    align-items: center;
}
.compare-cell-winner {
    background: #e8f5e9 !important;
    font-weight: 700;
    color: #2e7d32;
}

/* Summary table */
.compare-summary { margin-top: 4px; }
.compare-summary-title {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 10px;
}
.compare-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.compare-summary-table th {
    background: #f0f4f8;
    padding: 8px 10px;
    text-align: center;
    color: #555;
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
}
.compare-summary-table th:first-child { text-align: left; }
.compare-summary-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
    color: #444;
}
.compare-summary-metric {
    text-align: left !important;
    font-weight: 600;
    color: #555;
}
.compare-summary-table tr:hover { background: #fafafa; }

/* Comparar button in sidebar */
.compare-listing-btn {
    background: #fff;
    color: #00838f;
    border: 1.5px solid #00838f;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.compare-listing-btn:hover { background: #00838f; color: #fff; }
.compare-listing-btn.in-tray { background: #00838f; color: #fff; }
.compare-listing-btn.tray-full { border-color: #ccc; color: #999; cursor: default; }

@media (max-width: 768px) {
    .compare-tray { min-width: 95vw; }
    .compare-tray-inner { flex-wrap: wrap; }
    .compare-col-layout { flex-direction: column; }
    .compare-row-label-col { flex: none; width: 100%; border-right: none; border-bottom: 1px solid #e0e0e0; }
    .compare-col-header-blank { display: none; }
}

/* ─── Trial badge ──────────────────────────────────────────────────── */
.tier-badge.tier-trial {
    background: linear-gradient(135deg, #00838f, #2e7d32);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    cursor: default;
}

/* ─── Trial expired banner ─────────────────────────────────────────── */
.trial-expired-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 4000;
    background: #1a2634;
    color: #ecf0f1;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
.trial-upgrade-btn {
    background: #00838f;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.trial-upgrade-btn:hover { background: #006064; }
.trial-banner-close {
    background: none;
    border: none;
    color: #aac;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    padding: 0 4px;
}

/* ─── Upgrade modal subtitle ───────────────────────────────────────── */
.upgrade-subtitle {
    font-size: 12px;
    color: #888;
    margin: -6px 0 12px;
}

/* ─── App toast notifications ─────────────────────────────────────── */
.app-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 20000;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 420px;
    text-align: center;
    pointer-events: none;
}
.app-toast.app-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.app-toast-success { background: #27ae60; }
.app-toast-info    { background: #2c3e50; }
.app-toast-error   { background: #e74c3c; }

/* ─── Welcome onboarding modal ─────────────────────────────────────── */
.welcome-onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.welcome-onboarding-card {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 16px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}
.welcome-onboarding-header {
    background: linear-gradient(135deg, #1a2634 0%, #243b55 100%);
    padding: 28px 28px 24px;
    text-align: center;
}
.welcome-onboarding-badge {
    display: inline-block;
    background: rgba(0,131,143,0.3);
    border: 1px solid #00838f;
    color: #7ee8ef;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 14px;
    letter-spacing: 0.03em;
}
.welcome-onboarding-title {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 8px;
}
.welcome-onboarding-sub {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin: 0;
    line-height: 1.5;
}
.welcome-onboarding-steps {
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.welcome-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.welcome-step-num {
    width: 28px;
    height: 28px;
    background: #00838f;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
}
.welcome-step-title {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 3px;
}
.welcome-step-desc {
    font-size: 12px;
    color: #7f8c8d;
    line-height: 1.5;
}
.welcome-onboarding-footer {
    padding: 0 28px 24px;
    text-align: center;
}
.welcome-onboarding-cta {
    width: 100%;
    background: #00838f;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 13px 24px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 10px;
}
.welcome-onboarding-cta:hover { background: #006064; }
.welcome-trial-note {
    font-size: 11px;
    color: #aaa;
    line-height: 1.4;
}
