/* PropFlow — Dashboard studio (grille personnalisable) */

#dashboard .pf-hero--compact .pf-hero__inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    max-width: none;
}

.dash-studio-toggle {
    appearance: none;
    flex: 0 0 auto;
    margin: 0;
    padding: 10px 14px;
    min-height: 44px;
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 90%, transparent);
    border-radius: 10px;
    background: transparent;
    color: var(--pro-text-muted, #64748b);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-studio-toggle.is-on,
body.dash-studio-on .dash-studio-toggle {
    background: transparent;
    color: var(--pro-text, #0f172a);
    border-color: var(--pro-text, #0f172a);
}

.dash-studio-hint {
    display: none;
    margin: 0 16px 10px;
    padding: 0;
    border-radius: 0;
    background: none;
    color: var(--pro-text-muted, #64748b);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
}

body.dash-studio-on .dash-studio-hint {
    display: block;
}

.dash-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 12px;
    padding: 0 12px 24px;
    box-sizing: border-box;
}

body.dash-studio-on #dashboardBoard {
    padding-bottom: calc(58vh + 12px);
}

body.dash-studio-on .fab-floating {
    display: none !important;
}

#dashboardHost.dash-shell,
#dashboardFeed.dash-feed {
    display: contents;
}

#dashboard.is-dash-feed .dash-feed.analyse-feed {
    padding: 0;
    max-width: none;
    margin: 0;
}

.dash-w {
    min-width: 0;
    position: relative;
}

.dash-w__close {
    appearance: none;
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: color-mix(in srgb, var(--pro-surface-elevated, #fff) 82%, transparent);
    color: var(--pro-text-muted, #64748b);
    font: inherit;
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-w.is-off .dash-w__close,
body.dash-studio-on .dash-w__close {
    display: none;
}

.dash-w[data-size='full'] {
    grid-column: 1 / -1;
}

.dash-w[data-size='half'] {
    grid-column: span 1;
}

.dash-w.is-off {
    display: none !important;
}

body.dash-studio-on .dash-w.is-off {
    display: flex !important;
    flex-direction: column;
    grid-column: 1 / -1;
    opacity: 0.42;
    outline: 1px dashed color-mix(in srgb, var(--pro-text-muted, #64748b) 45%, transparent);
    outline-offset: 3px;
}

body.dash-studio-on .dash-w--tile.is-off {
    display: block !important;
}

.dash-w__bar {
    display: none;
}

body.dash-studio-on .dash-w__bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    padding: 4px;
    min-height: 44px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--pro-text, #0f172a) 6%, transparent);
}

.dash-w__grip {
    cursor: grab;
    padding: 4px 6px;
    border: none;
    background: transparent;
    color: var(--pro-text-muted, #64748b);
    font-size: 0.9rem;
    line-height: 1;
}

.dash-w__grip:active {
    cursor: grabbing;
}

.dash-w__name {
    flex: 1;
    min-width: 0;
    font-size: 0.6875rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pro-text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-w__btn {
    appearance: none;
    margin: 0;
    padding: 8px 10px;
    min-height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 8px;
    background: var(--pro-surface-elevated, #fff);
    color: var(--pro-text, #0f172a);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-w__btn--move {
    flex: 0 0 auto;
    font-size: 0.9375rem;
    line-height: 1;
}

.dash-w.is-dragging {
    opacity: 0.55;
}

.dash-w.is-drop {
    outline: 1px dashed color-mix(in srgb, var(--pro-text, #0f172a) 35%, transparent);
    outline-offset: 2px;
}

/* Tiles KPI */
.dash-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 88px;
    padding: 14px 40px 12px 14px;
    border-radius: 12px;
    background: var(--pro-surface-elevated, #f0eef5);
    box-shadow: var(--pro-shadow-sm, 0 1px 2px rgba(26, 24, 22, 0.04));
    box-sizing: border-box;
}

.dash-tile__lab {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: none;
    line-height: 1.3;
    color: var(--pro-text-muted, #64748b);
}

.dash-tile__val {
    font-size: 1.35rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--pro-text, #0f172a);
    line-height: 1.15;
}

.dash-tile__val.is-pos {
    color: color-mix(in srgb, var(--pro-success, #047857) 40%, #047857);
}

.dash-tile__val.is-neg {
    color: var(--pro-danger, #b91c1c);
}

.dash-tile__meta {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--pro-text-muted, #64748b);
}

.dash-year {
    padding: 12px 12px 10px;
    border-radius: 12px;
    background: var(--pro-surface-elevated, #f0eef5);
    box-shadow: var(--pro-shadow-sm, 0 1px 2px rgba(26, 24, 22, 0.04));
}

.dash-year__lab {
    margin: 0 36px 8px 2px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: none;
    line-height: 1.3;
    color: var(--pro-text-muted, #64748b);
}

.dash-year__row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 72px;
}

.dash-year__col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    height: 100%;
}

.dash-year__bar {
    width: 100%;
    max-width: 18px;
    border-radius: 4px 4px 2px 2px;
    background: #111827;
    min-height: 3px;
}

.dash-year__bar.is-neg {
    background: color-mix(in srgb, var(--pro-danger, #b91c1c) 70%, #111827);
}

.dash-year__m {
    font-size: 0.5625rem;
    font-weight: 700;
    color: var(--pro-text-muted, #64748b);
}

.dash-rank {
    padding: 12px 12px 10px;
    border-radius: 12px;
    background: var(--pro-surface-elevated, #f0eef5);
    box-shadow: var(--pro-shadow-sm, 0 1px 2px rgba(26, 24, 22, 0.04));
}

.dash-rank__lab {
    margin: 0 36px 8px 2px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: none;
    line-height: 1.3;
    color: var(--pro-text-muted, #64748b);
}

.dash-rank__row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 2px;
}

.dash-rank__n {
    flex: 0 0 1.1rem;
    font-size: 0.6875rem;
    font-weight: 750;
    color: var(--pro-text-muted, #64748b);
}

.dash-rank__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.8125rem;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-rank__val {
    font-size: 0.8125rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.dash-rank__val.is-pos {
    color: color-mix(in srgb, var(--pro-success, #047857) 40%, #047857);
}

.dash-rank__val.is-neg {
    color: var(--pro-danger, #b91c1c);
}

.dash-rank__empty {
    margin: 0;
    font-size: 0.75rem;
    color: var(--pro-text-muted, #64748b);
}

/* Palette — bottom sheet téléphone */
.dash-palette {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--pro-dock-height, 60px) + env(safe-area-inset-bottom, 0px));
    z-index: 10020;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    max-height: min(58vh, 520px);
    margin: 0;
    padding: 0 16px 12px;
    box-sizing: border-box;
    border-radius: 18px 18px 0 0;
    background: var(--pro-surface-elevated, #fff);
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 85%, transparent);
    border-bottom: none;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.16);
}

.dash-palette[hidden] {
    display: none !important;
}

.dash-palette__grab {
    flex: 0 0 auto;
    width: 40px;
    height: 4px;
    margin: 10px auto 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pro-text-muted, #64748b) 45%, transparent);
}

.dash-palette__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 2px;
}

.dash-palette__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 750;
}

.dash-palette__legend {
    margin: 0 0 10px;
    font-size: 0.75rem;
    font-weight: 550;
    line-height: 1.35;
    color: var(--pro-text-muted, #64748b);
}

.dash-palette__grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding-bottom: 4px;
}

.dash-palette__group-lab {
    margin: 0 0 8px;
    font-size: 0.6875rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pro-text-muted, #64748b);
}

.dash-palette__structs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-palette__struct {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.dash-palette__struct-move {
    appearance: none;
    flex: 0 0 44px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 90%, transparent);
    border-radius: 12px;
    background: transparent;
    color: var(--pro-text, #0f172a);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-palette__struct-move:disabled {
    opacity: 0.28;
    cursor: default;
}

.dash-palette__struct-main {
    appearance: none;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 90%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--pro-text-muted, #64748b) 8%, transparent);
    color: var(--pro-text-muted, #64748b);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-palette__struct.is-on .dash-palette__struct-main {
    background: transparent;
    color: var(--pro-text, #0f172a);
    border-color: var(--pro-text, #0f172a);
}

.dash-palette__chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-palette__chip {
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    min-height: 48px;
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 90%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--pro-text-muted, #64748b) 8%, transparent);
    color: var(--pro-text-muted, #64748b);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-palette__chip-t {
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.25;
    color: inherit;
}

.dash-palette__chip-h {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    color: inherit;
    opacity: 0.82;
}

.dash-palette__chip.is-on {
    background: transparent;
    color: var(--pro-text, #0f172a);
    border-color: var(--pro-text, #0f172a);
}

.dash-palette__foot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    align-items: stretch;
    gap: 8px;
    flex: 0 0 auto;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 80%, transparent);
}

.dash-palette__reset,
.dash-palette__ok {
    appearance: none;
    margin: 0;
    min-height: 48px;
    border-radius: 12px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dash-palette__reset {
    border: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 90%, transparent);
    background: transparent;
    color: var(--pro-text-muted, #64748b);
    text-decoration: none;
}

.dash-palette__ok {
    padding: 0 14px;
    border: 1px solid var(--pro-text, #0f172a);
    background: var(--pro-text, #0f172a);
    color: #fff;
}

@media (min-width: 720px) {
    .dash-palette {
        left: auto;
        right: 20px;
        bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        width: min(400px, calc(100vw - 40px));
        max-height: min(70vh, 640px);
        border-radius: 16px;
        border-bottom: 1px solid color-mix(in srgb, var(--pro-border, #e2e8f0) 85%, transparent);
    }

    body.dash-studio-on #dashboardBoard {
        padding-bottom: 24px;
    }
}

@media (max-width: 639px) {
    .dash-w[data-size='half'] {
        grid-column: 1 / -1;
    }

    body.dash-studio-on .dash-w[data-size='half'] {
        grid-column: span 1;
    }
}
