/* =========================================================================
 * CARETTA PERFORMANCE — Premium polish (global, ADITIV, non-structural)
 * Se incarca ULTIMUL. Doar imbunatatiri vizuale care NU afecteaza layout-ul:
 * randare font, scrollbar, selectie, focus accesibil. Zero risc de a "muta" ceva.
 * ========================================================================= */

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Accesibilitate: respecta preferinta sistemului pt miscare redusa (dezactiveaza animatiile/tranzitiile) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Scrollbar subtil, premium (Firefox + WebKit) */
* {
    scrollbar-width: thin;
    scrollbar-color: #c3ccd8 transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: #c3ccd8;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #9aa7b8; background-clip: content-box; }

/* Selectie text pe brandul Caretta */
::selection { background: rgba(0, 51, 73, 0.16); }

/* Focus vizibil si accesibil pe elementele interactive (audit: 10+ outline:none) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid rgba(0, 51, 73, 0.5);
    outline-offset: 2px;
}

/* Filtre dinamice pe coloana + cap de tabel sticky (toate tabelele mari) */
.ds-filter-table thead th { position: sticky; top: 0; z-index: 4; background: var(--surface-color); }
.ds-filter-table thead tr.ds-colfilter th { top: 34px; z-index: 3; padding: 3px 5px; background: var(--surface-color); border-bottom: 1px solid var(--border-color); }
.ds-filter-table thead tr.ds-colfilter input {
    width: 100%;
    min-width: 46px;
    box-sizing: border-box;
    padding: 3px 6px;
    font-size: 0.72rem;
    font-family: inherit;
    font-weight: 400;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-color);
    color: var(--text-main);
}
.ds-filter-table thead tr.ds-colfilter input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(0, 51, 73,0.12); }
.ds-filter-table tbody tr.ds-colfilter-hidden { display: none; }
/* Sortare pe coloana (click pe antet) */
.ds-filter-table thead tr:not(.ds-colfilter) th.ds-sortable { cursor: pointer; user-select: none; transition: color .12s ease; }
.ds-filter-table thead tr:not(.ds-colfilter) th.ds-sortable:hover { color: var(--primary-color); }
.ds-sort-ind { font-size: 0.78em; opacity: 0.85; }
body.dark-mode .ds-filter-table thead th,
body.dark-mode .ds-filter-table thead tr.ds-colfilter th { background: #1e293b; }

/* Badge clasificare partener (PLATINUM / GOLD / SILVER / BRONZE) */
.ds-tier {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
    white-space: nowrap;
}
.ds-tier i { font-size: 0.78rem; }
.ds-tier--platinum { background: #e6ecf5; color: #334a6b; border-color: #b9c6dd; }
.ds-tier--gold     { background: #fbeec3; color: #8a5a00; border-color: #e6c34d; }
.ds-tier--silver   { background: #eef2f7; color: #51607a; border-color: #cdd7e3; }
.ds-tier--bronze   { background: #f3e2d2; color: #8a5230; border-color: #d9ab85; }

/* Command Center — polish premium (ADITIV, non-structural: doar hover, umbre, cifre aliniate) */
#view-command-center .card { transition: box-shadow .18s ease, transform .14s ease; }
#view-command-center .cc-kpi:hover,
#view-command-center .cc-alert-chip:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
#view-command-center .cc-kpi > strong,
#view-command-center .cc-kpi small,
#view-command-center .cc-target-head strong,
#view-command-center .cc-target-foot b { font-variant-numeric: tabular-nums; }
#view-command-center .cc-kpi > strong { letter-spacing: -0.015em; }

/* Pill-uri de filtru mai compacte si aerisite (Command Center + DB Parteneri etc.) */
.slicer-container .slicer-btn { padding: 5px 11px; font-size: 0.78rem; }

/* DB Parteneri — carduri partener: hover premium tactil (aditiv) */
.crmx-card { transition: box-shadow .18s ease, transform .14s ease; }
.crmx-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }

/* DB Parteneri — 6 carduri macro (Total/Activi/BO/Fara/Necompletat/Juridic) incap pe un rand */
#view-crm .kpi-cards { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
#view-crm .kpi-card { transition: box-shadow .18s ease, transform .14s ease; }
#view-crm .kpi-card[id^="kpi-crm-"]:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-hover); }

/* DB Parteneri — filtre: randuri separate subtil (P2 premium arrangement) */
#crm-filter-panel .crm-fp-body .crm-fg { padding: 9px 0; border-top: 1px solid color-mix(in srgb, var(--border-color) 65%, transparent); }
#crm-filter-panel .crm-fp-body .crm-fg:first-child { border-top: none; padding-top: 2px; }

/* DB Parteneri — chips CLASIFICARE premium (punct colorat pe tier + culoare tier la activ) */
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val]:not([data-val="all"])::before {
    content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="PLATINUM"]::before { background: #8da7c9; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="GOLD"]::before { background: #e6c34d; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="SILVER"]::before { background: #aebccd; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="BRONZE"]::before { background: #cf9a6e; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="PLATINUM"].active { background: #334a6b; border-color: #334a6b; color: #fff; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="GOLD"].active { background: #8a5a00; border-color: #8a5a00; color: #fff; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="SILVER"].active { background: #51607a; border-color: #51607a; color: #fff; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="BRONZE"].active { background: #8a5230; border-color: #8a5230; color: #fff; }
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="PLATINUM"].active::before,
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="GOLD"].active::before,
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="SILVER"].active::before,
.crm-fg-chips[data-dim="clasificare"] .slicer-btn[data-val="BRONZE"].active::before { background: rgba(255,255,255,0.85); }

/* DB Parteneri — filtre avansate COLAPSABILE (inchise implicit = castig de spatiu).
 * Badge-ul "N filtre active" ramane vizibil chiar si colapsat. */
.crm-fp-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 2px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}
.crm-fp-toggle:hover { opacity: 0.82; }
.crm-fp-caret { font-size: 0.7em; opacity: 0.65; transition: transform .2s ease; }
#crm-filter-panel.is-open .crm-fp-caret { transform: rotate(180deg); }
.crm-fp-body {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
#crm-filter-panel.is-open .crm-fp-body { display: block; }
/* Cand e colapsat, panoul devine o bara subtire (head only) */
#crm-filter-panel:not(.is-open) { padding-bottom: 14px; }

/* Raport Zilnic + toate KPI cardurile — finisare premium:
 * cifre tabular-nums (nu mai "sar" la actualizare) + aliniere consistenta. */
.kpi-info h2 { font-variant-numeric: tabular-nums; }

/* Obiective — marker de pacing pe bara "Control target" (unde-ar trebui sa fii azi vs unde esti) */
.target-panel-progress { position: relative; }
.target-panel-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    margin-left: -1.5px;
    background: var(--text-strong, #0f172a);
    z-index: 2;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.65);
}

/* Goal Cockpit — BULLET CHART pacing (realizat vs planificat azi vs target 100%) */
.cc-bullet { grid-column: 1 / -1; position: relative; padding-top: 18px; }
.cc-bullet-track { position: relative; height: 18px; border-radius: 999px; background: #e8edf0; overflow: hidden; }
body.dark-mode .cc-bullet-track { background: #1e2b36; }
.cc-bullet-gap { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(224,0,77,0.12), rgba(224,0,77,0.12) 6px, rgba(224,0,77,0.22) 6px, rgba(224,0,77,0.22) 12px); }
.cc-bullet-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; transition: width .45s ease; }
.cc-bullet-fill.is-ontrack { background: linear-gradient(90deg, #003349, #1f6a86); }
.cc-bullet-fill.is-behind { background: linear-gradient(90deg, #E0004D, #ff4d80); }
.cc-bullet-marker { position: absolute; top: 14px; height: 26px; width: 3px; background: var(--text-strong, #0f172a); border-radius: 2px; box-shadow: 0 0 0 1.5px #fff; z-index: 3; transform: translateX(-50%); }
.cc-bullet-marker-lbl { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 0.6rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-strong, #0f172a); white-space: nowrap; }
.cc-bullet-scale { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 0.7rem; font-weight: 700; color: var(--text-muted); }
.cc-bullet-now { font-weight: 800; }

/* Command Center — bara de pacing aliniata la bullet chart-ul din Obiective (gap + marker AZI + fill navy/rosu) */
#view-command-center .cc-progress-wrap { position: relative; padding-top: 18px; }
#view-command-center .cc-progress-gap { position: absolute; top: 0; bottom: 0; z-index: 1; background: repeating-linear-gradient(45deg, rgba(224,0,77,0.12), rgba(224,0,77,0.12) 6px, rgba(224,0,77,0.22) 6px, rgba(224,0,77,0.22) 12px); }
#view-command-center .cc-progress-fill { z-index: 2; }
#view-command-center .cc-progress-fill.behind { background: linear-gradient(90deg, #E0004D, #ff4d80) !important; }
#view-command-center .cc-progress-fill.over { background: linear-gradient(90deg, #003349, #1f6a86) !important; }
#view-command-center .cc-progress-marker { top: 14px; bottom: auto; height: 26px; width: 3px; background: var(--text-strong, #0f172a); border-radius: 2px; box-shadow: 0 0 0 1.5px #fff; z-index: 3; transform: translateX(-50%); }
#view-command-center .cc-progress-marker::after { display: none; }
#view-command-center .cc-progress-marker .cc-bullet-marker-lbl { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 0.6rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-strong, #0f172a); white-space: nowrap; }

/* Command Center — FUNNEL comercial Oferte→Comenzi→Facturi→Incasari (bare proportionale cu valoarea) */
.cc-funnel { display: flex; flex-direction: column; gap: 2px; }
.cc-funnel-row { display: grid; grid-template-columns: 168px 1fr; align-items: center; gap: 14px; }
.cc-funnel-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cc-funnel-name { font-size: 0.82rem; font-weight: 800; color: var(--text-strong, #0f172a); }
.cc-funnel-cnt { font-size: 0.66rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cc-funnel-track { position: relative; height: 34px; background: #eef2f5; border-radius: 8px; overflow: hidden; display: flex; align-items: center; }
.cc-funnel-fill { position: absolute; top: 0; left: 0; bottom: 0; background: linear-gradient(90deg, #003349, #1f6a86); border-radius: 8px; transition: width .5s ease; min-width: 4px; }
.cc-funnel-fill--inc { background: linear-gradient(90deg, #002637, #1f6a86); }
.cc-funnel-val { position: relative; z-index: 2; padding: 0 12px; font-size: 0.84rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,0.30); }
.cc-funnel-step { margin: 1px 0 1px 182px; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.cc-funnel-step i { color: var(--caretta-red, #E0004D); margin-right: 5px; }
.cc-funnel-step b { color: var(--text-strong, #0f172a); font-weight: 900; }
body.dark-mode .cc-funnel-track { background: #1e2b36; }
@media (max-width: 680px) { .cc-funnel-row { grid-template-columns: 1fr; gap: 3px; } .cc-funnel-step { margin-left: 0; } }

/* Command Center — BottleneckInsightCard (cel mai mare blocaj de bani, acum + actiune) */
.cc-bottleneck { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; width: 100%; text-align: left; cursor: pointer; font: inherit; border: 1px solid var(--border-color); border-left: 4px solid var(--caretta-red, #E0004D); background: var(--surface-color); transition: box-shadow .18s ease, transform .14s ease; }
.cc-bottleneck:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.cc-bottleneck-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--caretta-red-soft, #fde6ee); color: var(--caretta-red, #E0004D); font-size: 1.3rem; flex-shrink: 0; }
.cc-bottleneck-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-bottleneck-eyebrow { font-size: 0.66rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--caretta-red, #E0004D); }
.cc-bottleneck-title { font-size: 1.05rem; font-weight: 800; color: var(--text-strong, #0f172a); line-height: 1.2; }
.cc-bottleneck-detail { font-size: 0.8rem; color: var(--text-muted); }
.cc-bottleneck-impact { text-align: right; display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.cc-bottleneck-impact-lbl { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.cc-bottleneck-impact strong { font-size: 1.3rem; font-weight: 900; color: var(--caretta-red, #E0004D); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.cc-bottleneck-impact em { font-size: 0.72rem; font-style: normal; font-weight: 700; color: var(--text-default, #1f2937); max-width: 240px; }
@media (max-width: 680px) { .cc-bottleneck { grid-template-columns: auto 1fr; } .cc-bottleneck-impact { grid-column: 1 / -1; text-align: left; margin-top: 8px; } }

/* Command Center — Aging bani de recuperat (0-30 navy / 31-60 amber / 60+ rosu critic) */
.cc-aging { margin: 2px 0 14px; }
.cc-aging-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #eef2f5; }
.cc-aging-seg { height: 100%; transition: width .5s ease; }
.cc-aging-seg.cc-aging-0 { background: #1f6a86; }
.cc-aging-seg.cc-aging-30 { background: #f59e0b; }
.cc-aging-seg.cc-aging-60 { background: var(--caretta-red, #E0004D); }
.cc-aging-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.cc-aging-lg { display: inline-flex; align-items: center; gap: 6px; }
.cc-aging-lg::before { content: ""; width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.cc-aging-lg-0::before { background: #1f6a86; }
.cc-aging-lg-30::before { background: #f59e0b; }
.cc-aging-lg-60::before { background: var(--caretta-red, #E0004D); }
.cc-aging-lg b { color: var(--text-strong, #0f172a); font-weight: 900; font-variant-numeric: tabular-nums; }
.cc-aging-lg-60 b { color: var(--caretta-red, #E0004D); }
body.dark-mode .cc-aging-bar { background: #1e2b36; }

/* Chart cards — hover premium consistent pe TOATE taburile cu grafice (Oferte, Incasari, Extreme, Vizite...) */
.card.chart-container { transition: box-shadow .2s ease, transform .14s ease; }
.card.chart-container:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
body.dark-mode .card.chart-container:hover { box-shadow: 0 22px 42px -20px rgba(0, 51, 73, 0.55); }

/* Card VMT — 3 valori (Com./Fact./Oferte) ca mini-tabel: valoare stanga, unitate dreapta */
#kpi-z-vmt-container h2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    line-height: 1.5;
    margin: 0;
    font-variant-numeric: tabular-nums;
}
#kpi-z-vmt-container h2 span { color: var(--text-muted); font-weight: 700; }

/* Carduri "Ce trebuie urmarit azi" — CTA navigatie clar (cerc + bounce la hover) */
#view-command-center .cc-alert-chip-cta {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-soft);
    transition: color .15s ease, background .15s ease, transform .15s ease;
}
#view-command-center .cc-alert-chip:hover .cc-alert-chip-cta {
    background: var(--caretta-navy-50);
    color: var(--caretta-navy);
    transform: translateY(3px);
}

/* Card "Bani de facturat" — sub-breakdown Industriale/Rezidential premium:
 * divider subtil + puncte colorate pe serie + valori aliniate la dreapta. */
.kpi-split {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid var(--border-color);
}
.kpi-split-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.76rem;
}
.kpi-split-label {
    color: var(--text-muted);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.kpi-split-label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kpi-split-ind .kpi-split-label::before { background: #7c3aed; }
.kpi-split-rez .kpi-split-label::before { background: #3b82f6; }
.kpi-split-val { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-split-ind .kpi-split-val { color: #7c3aed; }
.kpi-split-rez .kpi-split-val { color: #3b82f6; }
/* Rest de facturat: cap "In lucru" (fara punct) + sub-randuri Ind/Rez indentate + Custodie (amber, divider) */
.kpi-split-head .kpi-split-label { color: var(--text-color); font-weight: 800; }
.kpi-split-head .kpi-split-label::before { display: none; }
.kpi-split-sub { padding-left: 15px; }
.kpi-split-custodie { margin-top: 3px; padding-top: 7px; border-top: 1px dashed var(--border-color); }
.kpi-split-custodie .kpi-split-label { color: var(--text-color); font-weight: 800; }
.kpi-split-custodie .kpi-split-label::before { background: #f59e0b; }
.kpi-split-custodie .kpi-split-val { color: #b45309; }
body.dark-mode .kpi-split { border-top-color: rgba(148,163,184,0.25); }
body.dark-mode .kpi-split-custodie { border-top-color: rgba(148,163,184,0.25); }

/* Dark mode: scrollbar mai inchis ca sa nu "stralucesca" pe fundal inchis */
body.dark-mode * { scrollbar-color: #475569 transparent; }
body.dark-mode *::-webkit-scrollbar-thumb { background: #475569; }
body.dark-mode *::-webkit-scrollbar-thumb:hover { background: #64748b; }
