/* =========================================================
   MarketView - pagina Magazine
   ========================================================= */
.ms-head { margin-bottom: 10px; }
.ms-actions { display: flex; gap: 8px; align-items: center; }
.ms-actions .btn { height: 38px; }
.ms-more { width: 38px; padding: 0; }
.ms-actions .dropdown-item { display: flex; align-items: center; gap: 8px; text-decoration: none; }

/* KPI lanțuri */
.ms-kpis { display: grid; grid-template-columns: 1.3fr repeat(8, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.ms-kpi {
    display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left;
    background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text);
    box-shadow: var(--shadow); transition: border-color .15s;
}
button.ms-kpi:hover { border-color: #b8c7dd; }
.ms-kpi.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; background: #f5f9ff; }
.ms-kpi > div { min-width: 0; }
.ms-kpi small { display: block; font-size: 11.5px; color: #4b5669; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-kpi b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.3px; line-height: 1.3; }
.ms-kpi .muted, .ms-kpi .change { font-size: 11.5px; }
.ms-kpi-icon { font-size: 28px; color: #1f3b66; width: 40px; text-align: center; }

/* Grilă */
.ms-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr) 350px; gap: 10px; align-items: start; }
.ms-center { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Filtre */
.ms-filters { position: sticky; top: 64px; }
.ms-search { margin-bottom: 12px; }
.ms-search input { height: 34px; font-size: 12.5px; }
.check { display: flex !important; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text) !important; padding: 3px 0; cursor: pointer; margin: 0 !important; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); }
.ms-filters .btn-block { margin-top: 8px; height: 38px; }

/* Hartă */
.ms-map-card { position: relative; padding: 0; height: 400px; overflow: hidden; }
#msMap { position: absolute; inset: 0; background: #e8eef4; font-family: Inter, sans-serif; }
.ms-map-top {
    position: absolute; top: 10px; left: 10px; right: 10px; z-index: 600; pointer-events: none;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.ms-map-top > * { pointer-events: auto; }
.ms-county-select { position: relative; display: inline-flex; align-items: center; }
.ms-county-select select {
    appearance: none; -webkit-appearance: none; border: 0; background: #fff; border-radius: 8px;
    padding: 8px 36px 8px 12px; font-size: 17px; font-weight: 800; color: var(--text); cursor: pointer;
    box-shadow: 0 2px 10px rgba(16,24,40,.18); max-width: 260px;
}
.ms-county-select i { position: absolute; right: 12px; pointer-events: none; font-size: 12px; color: #3a4658; }
.ms-map-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ms-map-right .map-view-switch { box-shadow: 0 2px 10px rgba(16,24,40,.18); }
.ms-legend {
    list-style: none; margin: 0; padding: 8px 12px; background: rgba(255,255,255,.96); border-radius: 8px;
    box-shadow: 0 2px 10px rgba(16,24,40,.18); font-size: 11.5px;
}
.ms-legend li { display: flex; align-items: center; gap: 8px; padding: 2.5px 0; }
.ms-legend li > i { width: 15px; text-align: center; font-size: 14px; }
.ms-pin-indep { color: #2f7df6; }
.ms-pin-other { color: #6b7687; }
.ms-pin-selected { color: #16a34a; }
.ms-controls { right: 10px; bottom: 12px; }
.ms-map-count {
    position: absolute; left: 10px; bottom: 12px; z-index: 600; background: rgba(12,26,46,.8); color: #fff;
    font-size: 11.5px; padding: 4px 9px; border-radius: 6px;
}
.ms-map-count:empty { display: none; }

/* Marker-e */
.ms-marker { position: absolute; transform: translate(-50%, -100%); cursor: pointer; line-height: 1; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.35)); }
.ms-marker i { font-size: 22px; }
.ms-marker .bb { width: 20px; height: 20px; font-size: 10px; border: 2px solid #fff; box-shadow: none; transform: translateY(-2px); }
.ms-marker .bb-lidl b { font-size: 9px; }
.ms-marker-badge { transform: translate(-50%, -50%); }
.ms-marker:hover { z-index: 1000 !important; transform: translate(-50%, -100%) scale(1.2); }
.ms-marker-badge:hover { transform: translate(-50%, -50%) scale(1.2); }
.ms-marker-selected i { font-size: 34px; color: #16a34a; }
.ms-county-label { position: absolute; transform: translate(-50%, -50%); font: 700 13px Inter, sans-serif; letter-spacing: 1px; color: #6b7a90;
    white-space: nowrap; pointer-events: none; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.leaflet-tooltip.ms-tip { font-family: Inter, sans-serif; font-size: 12px; border-radius: 6px; padding: 5px 8px; }

/* Listă */
.ms-list { padding: 12px 14px; }
.ms-list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ms-list-head h3 { font-size: 15px; font-weight: 700; }
.ms-list-head h3 small { font-size: 13px; font-weight: 500; color: #3a4658; margin-left: 10px; }
.ms-list-tools { display: flex; gap: 8px; align-items: center; }
.ms-per { display: flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid #d5dce6; border-radius: 6px; padding: 0 0 0 10px; height: 28px; }
.ms-per select { border: 0; border-left: 1px solid #d5dce6; height: 26px; padding: 0 6px; border-radius: 0 6px 6px 0; background: #fff; }
.ms-columns { min-width: 190px; }
.ms-columns label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: 12.5px; cursor: pointer; border-radius: 5px; }
.ms-columns label:hover { background: #f5f7fb; }
.ms-table { font-size: 12px; }
.ms-table th { font-size: 11.5px; padding: 8px 6px; }
.ms-table th a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.ms-table th a i { font-size: 9px; color: #9aa6b8; }
.ms-table th.sorted a i { color: var(--primary); }
.ms-table td { padding: 7px 6px; }
.ms-table tbody tr { cursor: pointer; }
.ms-table tbody tr.selected { background: #eaf2ff !important; }
.ms-table tbody tr.selected td:nth-child(2) a { font-weight: 700; }
.ms-table input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.ms-table .col-name a { color: var(--primary); }
.ms-table .col-name { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-table .col-address { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-table .bb { width: 20px; height: 20px; font-size: 10px; }
.ms-row-menu { position: relative; }
.ms-row-menu > button { border: 0; background: none; width: 28px; height: 24px; border-radius: 5px; color: #3a4658; }
.ms-row-menu > button:hover { background: #eef2f7; }
.ms-row-menu .dropdown-menu { min-width: 170px; }
.ms-row-menu .dropdown-item { display: flex; gap: 8px; align-items: center; font-size: 12.5px; text-decoration: none; }
.ms-row-menu .dropdown-item.danger { color: var(--red); }
.ms-pager { margin-top: 12px; }

/* Detalii */
.ms-detail { padding: 0; overflow: hidden; position: sticky; top: 64px; max-height: calc(100vh - 74px); display: flex; flex-direction: column; }
#detailBody { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#detailBody[hidden], .ms-empty[hidden] { display: none; }
.ms-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.ms-empty i { font-size: 40px; color: #c3cdda; margin-bottom: 10px; }
.ms-banner {
    position: relative; height: 110px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 14px;
    background: linear-gradient(135deg, #1f3b66, #0c1a2e); overflow: hidden;
}
.ms-banner::before {
    content: ''; position: absolute; inset: 0;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 22px, transparent 22px 44px);
}
.ms-banner-icon { font-size: 50px; color: rgba(255,255,255,.9); position: relative; }
.ms-banner .bb { position: relative; width: 50px; height: 50px; font-size: 24px; border-radius: 10px; }
.ms-close {
    position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; border: 0;
    background: rgba(12,26,46,.75); color: #fff; font-size: 15px;
}
.ms-title { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 8px; }
.ms-title > div { flex: 1; min-width: 0; }
.ms-title h2 { font-size: 16px; font-weight: 800; line-height: 1.25; }
.ms-title p { margin: 3px 0 0; font-size: 12px; color: #4b5669; }
.ms-title .bb { width: 34px; height: 34px; font-size: 16px; border-radius: 7px; flex-shrink: 0; }
.ms-title .badge { flex-shrink: 0; }
.ms-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ms-tabs button {
    border: 0; background: none; padding: 8px 8px; font-size: 12px; color: #3a4658; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ms-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: var(--primary-soft); border-radius: 6px 6px 0 0; }
.ms-detail-body { padding: 12px 14px; overflow-y: auto; flex: 1; min-height: 0; }
.ms-tab { display: none; }
.ms-tab.active { display: block; }
.ms-dl { display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 7px 10px; margin: 0; font-size: 12px; }
.ms-dl dt { color: #4b5669; }
.ms-dl dd { margin: 0; color: var(--text); word-break: break-word; }
.ms-dl-wide { grid-template-columns: 140px minmax(0, 1fr); margin-top: 14px; }
.ms-dl a { float: right; font-weight: 600; }
.ms-subtitle { font-size: 13px; margin: 16px 0 8px; }
.ms-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ms-stats > div { border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; text-align: center; min-width: 0; }
.ms-stats b { display: block; font-size: 14px; font-weight: 800; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-stats small { display: block; font-size: 10px; color: #4b5669; }
.ms-stats-2 { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.ms-stats-2 b { font-size: 18px; margin: 0; }
.ms-stat-ic { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center; font-size: 13px; color: #fff; }
.ms-stat-ic.green { background: #22a846; } .ms-stat-ic.blue { background: #3b82f6; }
.ms-stat-ic.yellow { background: #f5b400; } .ms-stat-ic.purple { background: #8b5cf6; }
.sync-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.sync-dot.ok { background: var(--green); } .sync-dot.bad { background: var(--red); }
.agent-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.agent-chip .avatar { width: 24px; height: 24px; font-size: 10px; }
.ms-mini-table { margin-top: 10px; }
.small-note { font-size: 11px; margin-top: 8px; }
.ms-timeline { list-style: none; margin: 0; padding: 0 0 0 6px; }
.ms-timeline li { position: relative; padding: 0 0 14px 26px; font-size: 12.5px; }
.ms-timeline li::before { content: ''; position: absolute; left: 9px; top: 20px; bottom: 0; width: 2px; background: #e3e8ef; }
.ms-timeline li:last-child::before { display: none; }
.ms-timeline .tl-ic {
    position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: #fff;
}
.tl-ic.green { background: var(--green); } .tl-ic.blue { background: var(--primary); } .tl-ic.red { background: var(--red); } .tl-ic.orange { background: var(--orange); }
.ms-timeline small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.ms-notes-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.ms-detail-actions { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ms-detail-actions .btn { flex: 1; padding: 0 6px; font-size: 11.5px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12,26,46,.55); }
.modal-box {
    position: relative; background: #fff; border-radius: 12px; width: 640px; max-width: 100%; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.ms-close-dark { border: 0; background: none; font-size: 18px; color: #3a4658; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .field.invalid .input, .form-grid .field.invalid .select { border-color: var(--red); }
.form-grid .field .err { color: var(--red); font-size: 11px; margin-top: 3px; }
.form-grid .check { margin-top: 26px !important; }

/* Toast */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000;
    background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}

/* Responsive */
@media (max-width: 1500px) {
    .ms-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .ms-grid { grid-template-columns: 190px minmax(0, 1fr) 330px; }
}
@media (max-width: 1250px) {
    .ms-grid { grid-template-columns: 190px minmax(0, 1fr); }
    .ms-detail { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 900px) {
    .ms-grid { grid-template-columns: minmax(0, 1fr); }
    .ms-filters { position: static; }
    .ms-legend { display: none; }
    .ms-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 600px) {
    .ms-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-actions .btn span, .ms-actions a.btn { font-size: 12px; }
    .ms-map-card { height: 340px; }
    .ms-county-select select { font-size: 14px; }
}

/* Tabel compact (încape lângă panoul de detalii) */
.ms-table { font-size: 11.5px; }
.ms-table th { white-space: normal; line-height: 1.2; padding: 7px 5px; vertical-align: bottom; }
.ms-table td { padding: 6px 5px; }
.ms-table .col-name { max-width: 150px; }
.ms-table .col-address { max-width: 115px; }
.ms-table .col-type { max-width: 80px; white-space: normal; line-height: 1.2; }
.ms-table .col-activity { white-space: nowrap; }
@media (min-width: 1251px) and (max-width: 1650px) {
    .ms-grid { grid-template-columns: 185px minmax(0, 1fr) 330px; }
}
.ms-table th, .ms-table td { padding-left: 4px; padding-right: 4px; }
.ms-table .col-name { max-width: 132px; }
.ms-table .col-address { max-width: 100px; }
.ms-table .col-type { max-width: 70px; }
.ms-table th:first-child, .ms-table td:first-child { width: 24px; }

.ms-table .col-type { max-width: 80px; min-width: 64px; overflow: hidden; }
.ms-table .col-address { max-width: 88px; }


/* Carduri operaționale */
.ms-ops { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.ms-op .muted { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-op-ic { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.ms-op-ic.navy { background: #e6eefc; color: #1f3b66; }
.ms-op-ic.blue { background: #e8f0fe; color: var(--primary); }
.ms-op-ic.teal { background: #e0f5f2; color: #0f9488; }
.ms-op-ic.green { background: #e7f7ec; color: var(--green); }
.ms-op-ic.orange { background: #fff3e0; color: #e38a07; }
.ms-op-ic.red { background: var(--red-soft); color: var(--red); }
.ms-op-ic.purple { background: #f1ebff; color: #7c3aed; }
.ms-op[data-card="sync"].warn b, .ms-op[data-card="inactiv"].warn b { color: var(--red); }
@media (max-width: 1500px) { .ms-ops { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .ms-ops { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.ms-op { padding: 9px 10px; gap: 9px; align-items: flex-start; }
.ms-op small { white-space: normal; line-height: 1.2; min-height: 2.4em; display: flex; align-items: flex-end; }
.ms-op-ic { width: 34px; height: 34px; font-size: 15px; margin-top: 2px; }

