/* ============================================================================
   BARBAROS — parcel-track.css (Expéditions · Suivi colis, takes over #panel-tracking)
   ----------------------------------------------------------------------------
   Load after premium.css. Selectors `html[data-buld-theme] .pt-*` (0,2,1+). Tokens only: --buld-*,
   plus the module tones declared once on .pt-root below (carrier avatars and the violet/cyan
   step tones of the approved prototype, which have no --buld-* equivalent).

   collision list — the only !important declarations in this file:
     1. `#panel-tracking.pt-on > :not(.pt-root)` display:none — premium.css §tracking forces
        `.tracking-stats { display:grid !important }`; the legacy children must hide (reversible:
        ParcelTrack.disable() removes .pt-on).
     2. `.pt-search input` — buld-theme.css INPUTS/UNIFIED INPUTS force bg/border/radius with
        !important on input[type=search]; the field inside the .p-search pill must be chromeless.
     3. `.pt-filters select`, `.pt-form textarea/input/select`, `.pt-noteform textarea` height/radius/
        padding — same UNIFIED INPUTS block forces radius 12px + surface; we keep its colours and
        only restate radius/size so the controls match the 32px control rhythm; the invalid-field
        border (`.pt-form [aria-invalid]`) overrides the same forced border.
     4. reduced-motion block — buld-theme.css forces `transition … !important` on inputs/buttons.
   ============================================================================ */

html[data-buld-theme] #panel-tracking.pt-on > :not(.pt-root) { display: none !important; }

html[data-buld-theme] .pt-root {
    --pt-violet: #B58CFF; --pt-cyan: #4FD1E8; --pt-orange: #FF9F5A; --pt-red: #E5484D; --pt-green: #3DD598;
    --pt-tone: var(--buld-ink-3);
    color: var(--buld-ink-1);
    font-family: var(--buld-font-text, inherit);
    font-size: 13px; line-height: 1.45;
    min-width: 0;
}
html[data-buld-theme="light"] .pt-root { --pt-violet: #7B4FD9; --pt-cyan: #0E8FA6; --pt-orange: #C2660D; --pt-red: #D33A2B; --pt-green: #14AE5C; }
html[data-buld-theme] .pt-root *, html[data-buld-theme] .pt-root *::before, html[data-buld-theme] .pt-root *::after { box-sizing: border-box; }
html[data-buld-theme] .pt-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-buld-theme] .pt-root .pt-num { font-variant-numeric: tabular-nums; }
html[data-buld-theme] .pt-root .pt-muted { color: var(--buld-ink-3); }
html[data-buld-theme] .pt-root svg.lucide { width: 15px; height: 15px; flex: none; }

/* tones */
html[data-buld-theme] .pt-root [data-tone="neutral"] { --pt-tone: var(--buld-ink-3); }
html[data-buld-theme] .pt-root [data-tone="violet"]  { --pt-tone: var(--pt-violet); }
html[data-buld-theme] .pt-root [data-tone="info"]    { --pt-tone: var(--buld-cta); }
html[data-buld-theme] .pt-root [data-tone="cyan"]    { --pt-tone: var(--pt-cyan); }
html[data-buld-theme] .pt-root [data-tone="warning"] { --pt-tone: var(--buld-warning); }
html[data-buld-theme] .pt-root [data-tone="success"] { --pt-tone: var(--buld-success); }
html[data-buld-theme] .pt-root [data-tone="danger"]  { --pt-tone: var(--pt-orange); }

/* ---------------------------------------------------------------- header */
html[data-buld-theme] .pt-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 16px; }
html[data-buld-theme] .pt-head__t h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; color: var(--buld-ink-1); font-family: var(--buld-font-display, inherit); }
html[data-buld-theme] .pt-head__t p { margin: 3px 0 0; color: var(--buld-ink-3); font-size: 13px; }
html[data-buld-theme] .pt-head__a { display: flex; gap: 8px; flex-wrap: wrap; }
html[data-buld-theme] .pt-root .bx-btn svg.lucide { width: 14px; height: 14px; }
html[data-buld-theme] .pt-root .bx-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
html[data-buld-theme] .pt-root .bx-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- KPIs */
html[data-buld-theme] .pt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 0 0 14px; }
html[data-buld-theme] .pt-kpi { background: var(--buld-elevated); border: 1px solid var(--buld-hairline); border-radius: 14px; padding: 12px 14px; min-width: 0; }
html[data-buld-theme] .pt-kpi small { display: block; color: var(--buld-ink-3); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 650; }
html[data-buld-theme] .pt-kpi strong { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--buld-ink-1); }
html[data-buld-theme] .pt-kpi span { display: block; font-size: 12px; color: var(--buld-ink-3); margin-top: 2px; }
html[data-buld-theme] .pt-kpi[data-tone="warn"] strong { color: var(--buld-warning); }
html[data-buld-theme] .pt-kpi[data-tone="ok"] strong { color: var(--buld-success); }

html[data-buld-theme] .pt-note { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; color: var(--buld-ink-3); font-size: 12px; }
html[data-buld-theme] .pt-pane .pt-note { margin: 14px 0 0; }

/* ---------------------------------------------------------------- split */
html[data-buld-theme] .pt-split { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; align-items: start; }
html[data-buld-theme] .pt-side {
    background: var(--buld-elevated); border: 1px solid var(--buld-hairline); border-radius: 14px; padding: 10px;
    position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; min-width: 0;
}
html[data-buld-theme] .pt-root .pt-search.p-search { display: flex; width: auto; max-width: none; margin: 4px 4px 8px; }
html[data-buld-theme] body .pt-root .pt-search input[type="search"] { flex: 1; min-width: 0; width: 100%; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; height: 100% !important; border-radius: 0 !important; font-size: 13px !important; color: var(--buld-ink-1) !important; }
html[data-buld-theme] .pt-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 4px 10px; }
html[data-buld-theme] .pt-filters select { height: 30px !important; border-radius: 9px !important; padding: 0 8px !important; font-size: 12px !important; min-width: 0; width: 100%; color: var(--buld-ink-1); }

html[data-buld-theme] .pt-seg { display: flex; background: var(--buld-surface-2); border: 1px solid var(--buld-hairline); border-radius: 10px; padding: 3px; gap: 2px; margin: 0 4px 10px; overflow-x: auto; scrollbar-width: none; }
html[data-buld-theme] .pt-seg button { flex: 1; border: 0; background: transparent; color: var(--buld-ink-3); padding: 5px 8px; border-radius: 7px; font: inherit; font-weight: 600; font-size: 12.5px; white-space: nowrap; cursor: pointer; }
html[data-buld-theme] .pt-seg button:hover { color: var(--buld-ink-1); }
html[data-buld-theme] .pt-seg button.is-on { background: var(--buld-elevated); color: var(--buld-ink-1); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
html[data-buld-theme] .pt-seg .pt-n { color: var(--buld-ink-4); font-weight: 600; margin-left: 2px; }

html[data-buld-theme] .pt-list { display: grid; gap: 1px; }
html[data-buld-theme] .pt-item {
    display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: transparent; text-align: left;
    padding: 9px 10px; border-radius: 10px; color: var(--buld-ink-1); font: inherit; cursor: pointer; min-width: 0;
}
html[data-buld-theme] .pt-item:hover { background: var(--buld-hover); }
html[data-buld-theme] .pt-item.is-on { background: var(--buld-cta-soft); }
html[data-buld-theme] .pt-item:focus-visible, html[data-buld-theme] .pt-seg button:focus-visible { outline: 2px solid var(--buld-cta); outline-offset: 1px; }
html[data-buld-theme] .pt-item__g { flex: 1; min-width: 0; display: grid; gap: 1px; }
html[data-buld-theme] .pt-item__g b { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-buld-theme] .pt-item__g small { color: var(--buld-ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-buld-theme] .pt-item__g .pt-item__why { color: var(--buld-warning); white-space: normal; }
html[data-buld-theme] .pt-item__g .pt-item__why[data-sev="high"] { color: var(--buld-danger); }
html[data-buld-theme] .pt-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--buld-warning); }
html[data-buld-theme] .pt-dot[data-sev="high"] { background: var(--buld-danger); }
html[data-buld-theme] .pt-dot[data-sev="low"] { background: var(--buld-ink-4); }

/* carrier avatar */
html[data-buld-theme] .pt-av { display: inline-grid; place-items: center; flex: none; border-radius: 8px; font-weight: 800; font-size: 11px; color: #fff; background: var(--buld-ink-4); letter-spacing: .02em; }
html[data-buld-theme] .pt-av--sm { width: 32px; height: 32px; }
html[data-buld-theme] .pt-av--md { width: 30px; height: 30px; }
html[data-buld-theme] .pt-av--lg { width: 38px; height: 38px; font-size: 12px; border-radius: 10px; }
html[data-buld-theme] .pt-av[data-hue="red"] { background: var(--pt-red); }
html[data-buld-theme] .pt-av[data-hue="blue"] { background: var(--buld-cta); }
html[data-buld-theme] .pt-av[data-hue="violet"] { background: var(--pt-violet); }
html[data-buld-theme] .pt-av[data-hue="green"] { background: var(--pt-green); }
html[data-buld-theme] .pt-av[data-hue="orange"] { background: var(--pt-orange); }
html[data-buld-theme] .pt-av[data-hue="cyan"] { background: var(--pt-cyan); }
html[data-buld-theme] .pt-av[data-hue="none"] { background: var(--buld-surface-2); color: var(--buld-ink-3); border: 1px dashed var(--buld-divider); }

/* empty */
html[data-buld-theme] .pt-empty { display: grid; justify-items: center; gap: 4px; padding: 28px 12px; text-align: center; color: var(--buld-ink-3); }
html[data-buld-theme] .pt-empty b { color: var(--buld-ink-1); font-size: 14px; }
html[data-buld-theme] .pt-empty svg.lucide { width: 22px; height: 22px; margin-bottom: 4px; }
html[data-buld-theme] .pt-empty .bx-btn { margin-top: 8px; }

/* ---------------------------------------------------------------- detail */
html[data-buld-theme] .pt-main { min-width: 0; }
html[data-buld-theme] .pt-ttl { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 2px 0 12px; }
html[data-buld-theme] .pt-ttl h3 { margin: 0; font-size: 14px; font-weight: 680; color: var(--buld-ink-1); }
html[data-buld-theme] .pt-pane { background: var(--buld-elevated); border: 1px solid var(--buld-hairline); border-radius: 14px; padding: 16px; min-width: 0; }
html[data-buld-theme] .pt-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--pt-tone) 40%, transparent); background: color-mix(in srgb, var(--pt-tone) 14%, transparent);
    color: color-mix(in srgb, var(--pt-tone) 70%, var(--buld-ink-1));
}
html[data-buld-theme] .pt-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pt-tone); }

html[data-buld-theme] .pt-hero { background: var(--buld-surface-2); border: 1px solid var(--buld-hairline); border-radius: 12px; padding: 14px; margin: 0 0 14px; }
html[data-buld-theme] .pt-hero__top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
html[data-buld-theme] .pt-hero__c { display: flex; gap: 10px; align-items: center; min-width: 0; }
html[data-buld-theme] .pt-hero__c b { font-weight: 650; }
html[data-buld-theme] .pt-hero__cod { text-align: right; }
html[data-buld-theme] .pt-hero__cod small { display: block; color: var(--buld-ink-3); font-size: 11px; }
html[data-buld-theme] .pt-hero__cod b { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
html[data-buld-theme] .pt-prog { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 12px 0 4px; }
html[data-buld-theme] .pt-prog i { height: 5px; border-radius: 99px; background: var(--buld-hairline); }
html[data-buld-theme] .pt-prog i.is-d { background: var(--pt-tone); }
html[data-buld-theme] .pt-prog-l { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 11px; color: var(--buld-ink-3); }
html[data-buld-theme] .pt-prog-l .is-cur { color: var(--buld-ink-1); font-weight: 650; }

/* SLA alerts — each one carries its reason and its rule */
html[data-buld-theme] .pt-alerts { display: grid; gap: 8px; margin: 0 0 14px; }
html[data-buld-theme] .pt-alert {
    --sev: var(--buld-warning);
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px;
    background: color-mix(in srgb, var(--sev) 10%, transparent); border: 1px solid color-mix(in srgb, var(--sev) 35%, transparent);
}
html[data-buld-theme] .pt-alert[data-sev="high"] { --sev: var(--buld-danger); }
html[data-buld-theme] .pt-alert[data-sev="low"] { --sev: var(--buld-ink-3); }
html[data-buld-theme] .pt-alert > svg.lucide { color: var(--sev); margin-top: 1px; }
html[data-buld-theme] .pt-alert b { display: block; font-weight: 650; color: var(--buld-ink-1); }
html[data-buld-theme] .pt-alert .pt-why { display: block; color: var(--buld-ink-2); }
html[data-buld-theme] .pt-alert small { display: block; color: var(--buld-ink-3); font-size: 11.5px; margin-top: 2px; }

html[data-buld-theme] .pt-kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; margin: 0 0 4px; }
html[data-buld-theme] .pt-kv dt { color: var(--buld-ink-3); }
html[data-buld-theme] .pt-kv dd { margin: 0; color: var(--buld-ink-1); overflow-wrap: anywhere; }
html[data-buld-theme] .pt-kv dd a { color: var(--buld-cta); text-decoration: none; }
html[data-buld-theme] .pt-kv .pt-pre { white-space: pre-line; color: var(--buld-ink-2); }

html[data-buld-theme] .pt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

html[data-buld-theme] .pt-coord { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 16px 0 18px; padding-top: 14px; border-top: 1px solid var(--buld-hairline); }
html[data-buld-theme] .pt-sec { background: var(--buld-surface-2); border: 1px solid var(--buld-hairline); border-radius: 12px; padding: 10px 12px; min-width: 0; }
html[data-buld-theme] .pt-sec h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--buld-ink-3); font-weight: 650; }
html[data-buld-theme] .pt-sec h4 svg.lucide { width: 13px; height: 13px; }
html[data-buld-theme] .pt-row { display: flex; flex-wrap: wrap; gap: 6px; }
html[data-buld-theme] .pt-row:empty { display: none; }
html[data-buld-theme] .pt-noteform { display: flex; gap: 6px; align-items: flex-end; margin-top: 8px; }
html[data-buld-theme] .pt-noteform textarea { flex: 1; min-width: 0; resize: vertical; min-height: 34px; border-radius: 9px !important; padding: 6px 8px !important; font: inherit; font-size: 12.5px !important; }

html[data-buld-theme] .pt-lbl { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--buld-ink-3); font-weight: 650; margin: 0 0 10px; }
html[data-buld-theme] .pt-tl { list-style: none; margin: 0; padding: 0; position: relative; }
html[data-buld-theme] .pt-tl li { position: relative; padding: 0 0 16px 28px; }
html[data-buld-theme] .pt-tl li::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: -2px; width: 2px; background: var(--buld-hairline); }
html[data-buld-theme] .pt-tl li:last-child::before { display: none; }
html[data-buld-theme] .pt-tl li > i { position: absolute; left: 2px; top: 3px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--pt-tone); background: transparent; }
html[data-buld-theme] .pt-tl li.is-done > i { background: var(--pt-tone); }
html[data-buld-theme] .pt-tl li[data-kind="log"] > i { width: 10px; height: 10px; left: 4px; top: 5px; }
html[data-buld-theme] .pt-tl li.is-cur > i { box-shadow: 0 0 0 4px color-mix(in srgb, var(--pt-tone) 25%, transparent); }
html[data-buld-theme] .pt-tl li b { display: block; font-weight: 620; color: var(--buld-ink-1); }
html[data-buld-theme] .pt-tl li small { color: var(--buld-ink-3); font-size: 12px; }
html[data-buld-theme] .pt-tl li.is-fut { opacity: .5; }
html[data-buld-theme] .pt-tl__d { display: block; margin-top: 3px; color: var(--buld-ink-2); font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- sheets (rendered by BuldUX.sheet, outside .pt-root) */
html[data-buld-theme] .pt-form { display: grid; gap: 12px; color: var(--buld-ink-1); font-size: 13px; }
html[data-buld-theme] .pt-form p { margin: 0; }
html[data-buld-theme] .pt-muted { color: var(--buld-ink-3); }
html[data-buld-theme] .pt-fs { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
html[data-buld-theme] .pt-fs--row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
html[data-buld-theme] .pt-fs legend { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--buld-ink-3); font-weight: 650; margin: 0 0 6px; padding: 0; }
html[data-buld-theme] .pt-radio { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--buld-ink-1); }
html[data-buld-theme] .pt-radio input { accent-color: var(--buld-cta); margin: 0; }
html[data-buld-theme] .pt-radio em { font-style: normal; font-size: 11px; color: var(--buld-cta); font-weight: 600; }
html[data-buld-theme] .pt-field { display: grid; gap: 6px; }
html[data-buld-theme] .pt-field > span { font-size: 12px; color: var(--buld-ink-2); font-weight: 600; }
html[data-buld-theme] .pt-form textarea, html[data-buld-theme] .pt-form input[type="text"], html[data-buld-theme] .pt-form input[type="date"], html[data-buld-theme] .pt-form select {
    width: 100%; border-radius: 10px !important; padding: 8px 10px !important; font: inherit; font-size: 13px !important; color: var(--buld-ink-1);
}
html[data-buld-theme] .pt-form textarea { resize: vertical; line-height: 1.5; }
html[data-buld-theme] .pt-form [aria-invalid="true"] { border-color: var(--buld-danger) !important; }
html[data-buld-theme] .pt-err { color: var(--buld-danger); font-size: 12px; margin: -6px 0 0 !important; }
html[data-buld-theme] .pt-hint { color: var(--buld-ink-3); font-size: 12px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
    html[data-buld-theme] .pt-split { grid-template-columns: minmax(0, 1fr); }
    html[data-buld-theme] .pt-side { position: static; max-height: none; }
    html[data-buld-theme] .pt-list { max-height: 360px; overflow: auto; }
}
@media (max-width: 520px) {
    html[data-buld-theme] .pt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    html[data-buld-theme] .pt-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    html[data-buld-theme] .pt-kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
    html[data-buld-theme] .pt-kv dt { margin-top: 8px; font-size: 11px; }
    html[data-buld-theme] .pt-pane { padding: 12px; }
    html[data-buld-theme] .pt-head__a .bx-btn { flex: 1 1 auto; justify-content: center; }
    html[data-buld-theme] .pt-hero__cod { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
    html[data-buld-theme] .pt-root * { transition: none !important; animation: none !important; }
}
