/* =========================================================
   MarketView - Hartă interactivă (layout pe tot ecranul)
   ========================================================= */
:root {
    --mp-bg: #0b1627;
    --mp-card: #111f35;
    --mp-card-2: #162843;
    --mp-line: #22385a;
    --mp-text: #e8eef8;
    --mp-muted: #9fb0c8;
    --mp-cov-1: #ea4335;
    --mp-cov-2: #f7a33b;
    --mp-cov-3: #f6d743;
    --mp-cov-4: #9ad84f;
    --mp-cov-5: #1fae4b;
}

body.layout-full { background: var(--mp-bg); color: var(--mp-text); }
.layout-full .content { padding: 10px; }
.layout-full .topbar { gap: 16px; padding: 0 12px; height: 58px; border-bottom: 1px solid var(--mp-line); }
.layout-full .search { width: 480px; max-width: 34vw; }
.layout-full .search input { height: 38px; }
.brand-top { height: auto; padding: 0; }
.brand-top strong { font-size: 18px; }
.app-menu-btn { font-size: 18px; }
#appMenu .dropdown-menu { min-width: 230px; }
#appMenu .dropdown-item { display: flex; align-items: center; gap: 6px; text-decoration: none; }
.segmented-blue button.active { background: var(--primary); color: #fff; }
.fs-btn { width: 38px; justify-content: center; padding: 0; }

/* ---------------- Pagina ---------------- */
.mp-page { display: flex; flex-direction: column; gap: 10px; min-height: calc(100vh - 78px); }
.layout-full .card { background: var(--mp-card); border-color: var(--mp-line); color: var(--mp-text); box-shadow: none; }
.layout-full .card-head h3 { color: #fff; }
.layout-full .muted { color: var(--mp-muted); }
.layout-full .select, .layout-full .input {
    background: #0f1c30; border-color: #2a4064; color: #fff; height: 36px;
}
.layout-full .field label { color: #c9d4e4; font-size: 12.5px; }
.layout-full .table th { background: transparent; color: #c9d4e4; border-color: var(--mp-line); }
.layout-full .table td { border-color: #1b2e4b; color: var(--mp-text); }
.layout-full .table tbody tr:hover { background: #172a47; }
.layout-full .table a { color: #8ab8ff; }
.layout-full .segmented-light { background: #0f1c30; }
.layout-full .segmented-light button { color: #c9d4e4; }
.layout-full .segmented-light button.active { background: var(--primary); color: #fff; }

/* KPI piață */
.mp-kpis { display: grid; grid-template-columns: 1.45fr repeat(8, minmax(0, 1fr)); gap: 8px; }
.mp-kpi {
    display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left;
    background: var(--mp-card); border: 1px solid var(--mp-line); border-radius: 8px;
    padding: 10px 12px; color: var(--mp-text); transition: border-color .15s, background .15s;
}
button.mp-kpi:hover { border-color: #3a5a88; background: var(--mp-card-2); }
.mp-kpi.active { border-color: var(--primary); background: #13305a; box-shadow: 0 0 0 1px var(--primary) inset; }
.mp-kpi > div { min-width: 0; }
.mp-kpi small { display: block; font-size: 12px; color: #d3dcea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-kpi b { display: block; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -.3px; line-height: 1.25; }
.mp-kpi .muted { font-size: 12px; }
.mp-kpi em { display: block; font-style: normal; font-size: 10px; color: var(--mp-muted); }
.mp-kpi-icon { font-size: 30px; color: #dbe6f5; width: 44px; text-align: center; }
.mp-kpi-total b { font-size: 24px; }

/* Grilă principală */
.mp-grid {
    flex: 1; display: grid; gap: 10px;
    grid-template-columns: 205px minmax(0, 1fr) 372px;
    grid-template-rows: minmax(560px, 1fr) 185px;
}
.mp-side { grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.mp-card { padding: 12px 14px; }
.mp-side .field { margin-bottom: 10px; }
.mp-side .btn-block { margin-top: 6px; height: 38px; }
.mp-side .card-head a { font-size: 12.5px; }

.mp-legend { flex: 1; overflow-y: auto; }
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 12.5px; color: #dbe4f0; }
.legend-note { font-size: 10.5px; color: var(--mp-muted); margin: 6px 0 10px; line-height: 1.4; }
.legend-color { background: #0f1c30; border: 1px solid var(--mp-line); border-radius: 8px; padding: 10px; }
.legend-color h4 { font-size: 12.5px; margin: 0 0 6px; color: #fff; }
.legend-color-head { margin-bottom: 10px; }
.legend-color-head .segmented-light { display: flex; }
.legend-color-head .segmented-light button { flex: 1; }
.legend-cov { list-style: none; margin: 0; padding: 0; }
.legend-cov li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 3px 0; color: #dbe4f0; }
.legend-cov i { width: 13px; height: 13px; border-radius: 50%; }

/* Harta */
.mp-map {
    grid-column: 2; grid-row: 1; position: relative; border-radius: 10px; overflow: hidden;
    border: 1px solid var(--mp-line); background: radial-gradient(ellipse at 45% 45%, #1d3350 0%, #0d1a2c 75%);
}
#leafletMap { position: absolute; inset: 0; background: transparent; font-family: Inter, sans-serif; }
.mp-map-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--mp-muted); z-index: 500; pointer-events: none; }
.view-map .leaflet-tile-pane { filter: brightness(.55) saturate(.55) hue-rotate(-10deg) contrast(1.05); }
.leaflet-container .leaflet-control-attribution { background: rgba(11,22,39,.7); color: #9fb0c8; font-size: 10px; }
.leaflet-container .leaflet-control-attribution a { color: #c9d4e4; }

.county-path { transition: fill-opacity .15s; }

/* Etichete județe */
.cl {
    position: absolute; transform: translate(-50%, -50%);
    text-align: left; white-space: nowrap; pointer-events: none;
    color: #13233a; font-family: Inter, sans-serif; line-height: 1;
}
.cl-name { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .2px; text-align: center; margin-bottom: 3px;
    text-shadow: 0 0 3px rgba(255,255,255,.6); }
.cl-rows { display: inline-flex; flex-direction: column; gap: 1px; }
.cl-rows span { display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; }
.cl-rows .bb { width: 11px; height: 11px; font-size: 7px; border-radius: 2px; border-width: 1px; box-shadow: none; }
.cl-rows .bb-lidl b { font-size: 6px; }
.cl-box { display: flex; flex-direction: column; align-items: center; }
.cl.cl-selected .cl-name { color: #0b3b8f; }
.zl-1 .cl-rows { display: none; }
.zl-1 .cl-name { font-size: 9px; }
.zl-3 .cl-name { font-size: 13px; }
.zl-3 .cl-rows span { font-size: 12px; gap: 5px; }
.zl-3 .cl-rows .bb { width: 14px; height: 14px; font-size: 8.5px; }
.view-satellite .cl-box { background: rgba(255,255,255,.88); border-radius: 6px; padding: 4px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.cl-country { position: absolute; transform: translate(-50%, -50%); font: 700 16px Inter, sans-serif; letter-spacing: 1.5px;
    color: rgba(190, 210, 235, .75); white-space: nowrap; text-align: center; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.6); line-height: 1.2; }

.leaflet-tooltip.mp-tip {
    background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 9px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35); font-family: Inter, sans-serif; font-size: 12px; min-width: 190px;
}
.leaflet-tooltip.mp-tip::before { display: none; }
.mp-tip b { display: block; font-size: 13px; margin-bottom: 5px; }
.mp-tip div { display: flex; justify-content: space-between; gap: 14px; color: #c9d4e4; padding: 1px 0; }
.mp-tip div span:last-child { color: #fff; font-weight: 600; }

/* Panou județ */
.mp-panel {
    grid-column: 3; grid-row: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
    padding: 0; background: #fff !important; color: var(--text) !important; border: 0 !important;
}
.mp-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 0; }
.mp-panel-head h2 { font-size: 23px; font-weight: 800; color: var(--text); }
.mp-panel .close { border: 0; background: none; font-size: 20px; color: #3a4658; }
.mp-cov-pill {
    align-self: flex-end; margin: 6px 18px 0; background: #dcf5e3; color: #11662f;
    font-weight: 700; font-size: 12.5px; padding: 5px 12px; border-radius: 14px;
}
.mp-big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 18px; }
.mp-big > div, .mp-chains > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mp-big b { display: block; font-size: 21px; font-weight: 800; }
.mp-big small, .mp-chains small { display: block; font-size: 11.5px; color: #4b5669; white-space: nowrap; }
.mp-chains { display: grid; grid-template-columns: auto auto auto 1fr; gap: 16px; padding: 6px 18px 12px; border-bottom: 1px solid var(--border); }
.mp-chains b { font-size: 18px; font-weight: 700; }
.mp-tabs { display: flex; gap: 4px; padding: 10px 14px 0; }
.mp-tabs button {
    flex: 1; border: 0; background: #f2f5f9; color: #3a4658; padding: 8px 6px; border-radius: 6px;
    font-size: 12.5px; font-weight: 500;
}
.mp-tabs button.active { background: var(--primary); color: #fff; }
.mp-panel-body { flex: 1; overflow-y: auto; padding: 10px 14px 12px; min-height: 0; }
.mp-tab { display: none; }
.mp-tab.active { display: block; }
.mp-mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 12px; }
.mp-mini-stats > div { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.mp-mini-stats small { display: block; font-size: 11px; color: #4b5669; }
.mp-mini-stats b { font-size: 18px; }
.mp-opp-full { list-style: none; margin: 0 0 12px; padding: 0; }
.mp-opp-full li { padding: 8px 0; border-bottom: 1px solid #eef1f5; font-size: 12.5px; }
.mp-opp-full .row { display: flex; justify-content: space-between; margin-bottom: 5px; }

/* Rândul de jos */
.mp-bottom { grid-column: 2 / span 2; grid-row: 2; display: grid; grid-template-columns: 1.15fr 1.15fr .95fr 1fr; gap: 10px; min-height: 0; }
.mp-bottom .mp-card { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.mp-bottom .card-head { margin-bottom: 6px; }
.mp-bottom .card-head h3 { font-size: 13px; }
.mp-dist { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; align-items: center; flex: 1; min-height: 0; }
.mp-dist .donut-wrap { height: 120px; }
.mp-dist .donut-center b { color: #fff; }
.mp-dist .donut-center small { color: var(--mp-muted); }
.mp-dist-legend { font-size: 11px; color: #dbe4f0; }
.mp-dist-legend td { padding: 1.5px 2px; }
.mp-dist-legend .bb { width: 12px; height: 12px; font-size: 7px; margin-right: 6px; vertical-align: -2px; border-width: 1px; box-shadow: none; }
.mp-chart { flex: 1; height: auto; min-height: 0; }
.layout-full .hbar { grid-template-columns: 110px minmax(0, 1fr) 42px; padding: 4px 0; font-size: 12px; color: #dbe4f0; }
.layout-full .hbar-track { background: transparent; height: 13px; }
.layout-full .hbar > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-opp-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.mp-opp-list li { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.mp-opp-list .ic { color: #ff6b5b; font-size: 16px; width: 18px; text-align: center; }
.mp-opp-list .txt { flex: 1; min-width: 0; font-size: 10.5px; color: var(--mp-muted); line-height: 1.3; }
.mp-opp-list .txt b { display: block; font-size: 12px; color: #fff; }
.mp-opp-list button {
    border: 0; background: #1d4ed8; color: #fff; font-size: 11px; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
}
.mp-opp-list button:hover { background: var(--primary); }

/* Ecran complet */
:fullscreen body.layout-full, body.layout-full:fullscreen { overflow: auto; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1500px) {
    .mp-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .mp-grid { grid-template-columns: 195px minmax(0, 1fr) 350px; }
    .mp-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 185px 185px; }
    .mp-grid { grid-template-rows: minmax(560px, 1fr) auto; }
}
@media (max-width: 1150px) {
    .mp-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
    .mp-side, .mp-map, .mp-panel, .mp-bottom { grid-column: 1; grid-row: auto; }
    .mp-map { height: 620px; }
    .mp-panel { height: 640px; }
    .mp-side { flex-direction: row; flex-wrap: wrap; }
    .mp-side > .card { flex: 1 1 280px; }
    .layout-full .search { width: auto; flex: 1; max-width: none; }
    .brand-top span { display: none; }
}
@media (max-width: 760px) {
    .mp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mp-bottom { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
    .mp-bottom .mp-card { height: 200px; }
    .mp-map { height: 480px; }
    #mapViewTop, .fs-btn { display: none; }
    .mp-big, .mp-chains { padding-left: 12px; padding-right: 12px; }
    .mp-chains { gap: 10px; }
}

.cl-compact .cl-rows { display: none; }


/* Pagina încape într-un singur ecran pe desktop */
@media (min-width: 1151px) {
    .mp-page { height: calc(100vh - 78px); min-height: 820px; }
    .mp-grid { grid-template-rows: minmax(0, 1fr) 185px; min-height: 0; }
    .mp-side { overflow: hidden; }
    .mp-legend { min-height: 0; }
    .legend-list li { padding: 3px 0; }
}
@media (min-width: 1151px) and (max-width: 1500px) {
    .mp-page { height: auto; }
    .mp-grid { grid-template-rows: 640px auto; }
}

/* Panoul alb: tabele cu text închis */
.layout-full .mp-panel .table th { color: #3a4658; background: #f5f7fa; border-color: var(--border); }
.layout-full .mp-panel .table td { color: var(--text); border-color: #eef1f5; }
.layout-full .mp-panel .table tbody tr:hover { background: #f5f8fd; }
.layout-full .mp-panel .table a { color: var(--primary); }
.layout-full .mp-panel .muted { color: var(--muted); }
.layout-full .mp-panel .mp-table th { padding: 7px 5px; }

/* Rândul de jos - compact */
@media (min-width: 1151px) { .mp-grid { grid-template-rows: minmax(0, 1fr) 200px; } }
.mp-bottom .card-head { flex-wrap: nowrap; }
.mp-bottom .card-head h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mp-bottom .segmented-light button { padding: 3px 8px; font-size: 11px; }
.mp-dist-legend td { padding: 0 2px; line-height: 1.45; }
.mp-dist-legend td:first-child { max-width: 0; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bara din hartă: indicatori, Hartă/Satelit, legendă */
.mp-map-top {
    position: absolute; top: 10px; left: 10px; right: 10px; z-index: 600;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none;
}
.mp-map-top > * { pointer-events: auto; }
.mp-map-top .tabs-pill { box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.mp-map-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mp-map-right .map-view-switch { box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.mp-legend-box {
    background: rgba(255,255,255,.96); color: var(--text); border-radius: 8px; padding: 9px 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,.3); font-size: 12px; min-width: 150px;
}
.mp-legend-box[hidden] { display: none; }
.mp-legend-box h5 { margin: 0 0 6px; font-size: 12px; font-weight: 700; }
.mp-legend-box .lg-grad { display: block; width: 150px; height: 9px; border-radius: 5px; }
.mp-legend-box .lg-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.mp-legend-box .lg-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.mp-legend-box .lg-row i { width: 11px; height: 11px; border-radius: 50%; }
.mp-controls { top: 58px; left: 10px; right: auto; bottom: auto; }

/* Etichete pe fundal închis */
.cl-light .cl-name, .cl-light .cl-rows span { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.55); }
@media (max-width: 760px) { .mp-map-top { flex-direction: column; } .mp-map-top .tabs-pill { font-size: 11px; } .mp-controls { top: auto; bottom: 16px; } }

/* Cu meniul lateral: mai puțin spațiu orizontal */
@media (max-width: 1700px) {
    .mp-grid { grid-template-columns: 185px minmax(0, 1fr) 340px; }
    .mp-map-top .tabs-pill button { padding: 4px 9px; font-size: 11.5px; }
    .mp-map-top .map-view-switch button { padding: 4px 11px; font-size: 11.5px; }
    .mp-bottom { grid-template-columns: 1.2fr 1.1fr .9fr 1fr; }
    .mp-dist { grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
    .mp-dist .donut-wrap { height: 96px; }
    .mp-dist .donut-center b { font-size: 15px; }
    .mp-dist-legend { font-size: 10.5px; }
    .mp-bottom .card-head h3 { font-size: 12px; }
    .mp-bottom .segmented-light button { padding: 3px 6px; font-size: 10.5px; }
    .layout-full .hbar { grid-template-columns: 80px minmax(0, 1fr) 36px; }
    .mp-kpi { padding: 9px 10px; gap: 8px; }
    .mp-kpi b { font-size: 18px; }
    .mp-kpi .bb-lg { width: 26px; height: 26px; font-size: 12px; }
}
