/* ═══════════════════════════════════════════════════════════════
   Campaigns → Delivery tracking  (trackingCampaignsUI.js)
   ───────────────────────────────────────────────────────────────
   The tracking-page promotion list, promotion detail, full-screen
   create / edit view with its phone preview, and the dialogs.
   Matches the redesign reference's TrackingPagePromotions.tsx.
   Shared pieces (tokens, stats, toolbar, dropdowns, table, pills,
   confirm dialog, coupon-fade-up) live in settings.v11.css.

   Layers: editor 1250 · detail and dialogs 1260 · confirms 1400.
   ═══════════════════════════════════════════════════════════════ */

.campaigns-settings {
    --tp-surface: #F1F1F2;          /* the reference's soft button fill */
    --tp-live: #008062;
    --tp-paused: #D97706;
    --tp-ended: #6B7280;
    --tp-danger: #EF4444;
}

[data-theme="dark"] .campaigns-settings {
    --tp-surface: rgba(255, 255, 255, 0.06);
}

@keyframes tp-spin {
    to { transform: rotate(360deg); }
}

.tp-spin {
    display: inline-flex;
    animation: tp-spin 0.9s linear infinite;
}

/* A layer re-rendered in place keeps still (see controller _fill). */
.tp-overlay--static,
.tp-overlay--static * { animation: none !important; }


/* ─── List ─── */
.campaigns-grid--tracking {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 90px 80px 110px;
    align-items: center;
}

.tp-cell-type {
    font-size: 14px;
    color: var(--flyer-text-secondary);
}

.tp-gear-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--flyer-border);
    border-radius: 10px;
    background: transparent;
    color: var(--flyer-text-muted);
    cursor: pointer;
    transition: background 0.12s;
}

.tp-gear-btn:hover { background: var(--flyer-bg-tertiary); }
.tp-gear-btn:focus-visible { outline: 2px solid var(--flyer-accent); outline-offset: 2px; }

/* ─── Ad card (the tracking page's promotion card) ─── */
.tp-ad-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: 124px;
    margin: 10px 10px 0;
    overflow: hidden;
    border-radius: 14px;
}

.tp-ad-media {
    position: relative;
    width: 130px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
}

.tp-ad-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tp-ad-placeholder {
    display: flex;
    color: rgba(0, 0, 0, 0.18);
}

.tp-ad-play {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.tp-ad-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
}

.tp-ad-title {
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 500;
    line-height: 135%;
    letter-spacing: -0.02em;
    color: #0A0A0A;
}

.tp-ad-cta {
    display: inline-block;
    max-width: 100%;
    padding: 5px 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-radius: 8px;
    background: #0A0A0A;
    font-size: 12px;
    font-weight: 600;
    color: #FFFFFF;
}

.tp-ad-domain {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #A3A3A3;
}

.tp-ad-domain span {
    font-size: 12px;
    font-weight: 400;
    line-height: 140%;
}

.tp-ad-domain svg { flex-shrink: 0; }

/* ─── Overlays ─── */
.tp-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-overlay--detail {
    z-index: 1260;
    padding: 24px;
    background: rgba(0, 0, 0, 0.45);
}

.tp-overlay--dialog {
    z-index: 1260;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
}

.tp-status-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 99px;
}

.tp-status-dot--live   { background: var(--tp-live); }
.tp-status-dot--paused { background: var(--tp-paused); }
.tp-status-dot--ended  { background: var(--tp-ended); }

/* ─── Promotion details, as the reference: the details on the left, the
   tracking page (the editor's preview) in the right 42%. Fixed size. ─── */
.tp-detail {
    position: relative;
    width: min(960px, 100%);
    height: min(760px, 88vh);
    display: flex;
    overflow: hidden;
    border-radius: 20px;
    background: var(--campaigns-modal-bg);
    box-shadow: 0 0 0 1px rgba(23, 23, 23, 0.08), 0 24px 80px rgba(0, 0, 0, 0.18);
    animation: coupon-fade-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

[data-theme="dark"] .tp-detail { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 80px rgba(0, 0, 0, 0.5); }

/* The dialogs' ✕, level with the title, in the corner over the preview */
.tp-detail-close { position: absolute; top: 24px; right: 32px; z-index: 1; }

.tp-detail-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tp-detail-head {
    flex-shrink: 0;
    padding: 28px 32px 20px;
}

.tp-detail-title {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--flyer-text);
}

.tp-detail-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 32px 8px;
}

/* Views / Clicks / CTR */
.tp-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.tp-detail-stat {
    padding: 20px 16px;
    border: 1px solid var(--flyer-border);
    border-radius: 12px;
}

.tp-detail-stat-label {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 500;
    color: var(--flyer-text-muted);
}

.tp-detail-stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--flyer-text);
}

.tp-detail-section {
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--flyer-text);
}

.tp-detail-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
    padding: 16px 20px;
    border: 1px solid var(--flyer-border);
    border-radius: 12px;
}

.tp-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.tp-detail-label {
    flex-shrink: 0;
    font-size: 14px;
    color: var(--flyer-text-muted);
}

.tp-detail-value {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: var(--flyer-text);
}

.tp-detail-value--live   { color: var(--tp-live); }
.tp-detail-value--paused { color: var(--tp-paused); }
.tp-detail-value--ended  { color: var(--tp-ended); }

/* Edit / Pause or Resume / Delete */
.tp-detail-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 14px 32px 28px;
}

.tp-detail-btn {
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--flyer-border);
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--flyer-text);
    cursor: pointer;
    transition: background 120ms ease;
}

.tp-detail-btn svg,
.tp-detail-btn .material-symbols-rounded { color: var(--flyer-text-muted); }
.tp-detail-btn:not(:disabled):hover { background: var(--flyer-surface-hover); }
.tp-detail-btn:disabled { opacity: 0.5; cursor: default; }
.tp-detail-btn:focus-visible { outline: 2px solid var(--flyer-accent); outline-offset: 2px; }
.tp-detail-btn--danger,
.tp-detail-btn--danger svg,
.tp-detail-btn--danger .material-symbols-rounded { color: var(--tp-danger); }
.tp-detail-btn--danger:not(:disabled):hover { background: #FEF2F2; }
[data-theme="dark"] .tp-detail-btn--danger:not(:disabled):hover { background: rgba(239, 68, 68, 0.08); }

/* Right: the tracking page, as the editor previews it, with this promotion's card.
   The phone is fitted (fitPhone) to the inner box, which stays clear of the ✕. */
.tp-detail-preview {
    flex: 0 0 42%;
    min-width: 0;
    display: flex;
    box-sizing: border-box;
    padding: 64px 24px 16px;
    overflow: hidden;
    background: var(--campaigns-pane-bg);
}

.tp-detail-preview-fit {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

/* ─── Create / edit: the reference's editor ───
   Laid out like the print campaign wizard, half each: the tracking page preview on
   the left, the form on the right under a back arrow, over one wide
   Publish button. */
.tp-editor {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: flex;
    overflow: hidden;
    background: var(--campaigns-modal-bg);
    animation: coupon-fade-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tp-editor-main {
    order: 2;
    flex: 1;
    min-width: 380px;
    border-left: 1px solid var(--flyer-border);
    container-type: inline-size;   /* the form lays itself out by its own width */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--campaigns-modal-bg);
}

.tp-editor-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 70px;
    padding: 0 16px;
}

.tp-editor-back {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 99px;
    background: transparent;
    color: var(--flyer-text-secondary);
    cursor: pointer;
    transition: background 120ms ease;
}

.tp-editor-back:hover { background: var(--flyer-surface-hover, #F9FAFB); }

.tp-editor-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    color: var(--flyer-text);
}

.tp-editor-form {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.tp-editor-fields {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 28px 42px 48px;
}

.tp-label {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--flyer-text);
}

.tp-label--type { margin-bottom: 10px; }

.tp-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tp-label-row .tp-label { margin-bottom: 0; }
.tp-video-logos { display: flex; align-items: center; gap: 8px; color: #000000; }
[data-theme="dark"] .tp-video-logos { color: #FFFFFF; }

/* Promotion type: five tiles */
.tp-type-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.tp-type-tile {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 8px;
    border: 1.5px solid var(--flyer-border);
    border-radius: 12px;
    background: transparent;
    font-family: inherit;
    text-align: center;
    color: var(--flyer-text-muted);
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.tp-type-tile:hover:not(:disabled):not(.tp-type-tile--active) { background: var(--flyer-surface-hover, #F9FAFB); }

.tp-type-tile-label {
    min-height: 2.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    line-height: 140%;
    color: var(--flyer-text-secondary);
}

.tp-type-tile--active {
    border-color: var(--flyer-accent);
    background: var(--flyer-accent-light);
    color: var(--flyer-accent);
}

.tp-type-tile--active .tp-type-tile-label { font-weight: 600; color: var(--flyer-accent); }
.tp-type-tile:disabled { opacity: 0.45; cursor: not-allowed; }

/* Card color, with Card image beside it */
.tp-card-row { display: flex; gap: 16px; }
.tp-card-row > div { flex: 1; min-width: 0; }

/* In the narrow column beside the preview: the types in rows of three,
   and Card image under Card color. */
@container (max-width: 560px) {
    .tp-type-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .tp-card-row  { flex-direction: column; gap: 32px; }
}

.tp-swatch-row {
    display: flex;
    gap: 8px;
}

.tp-swatch {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    border: 2.5px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 150ms ease;
}

.tp-swatch--active { border-color: var(--flyer-accent); }

.tp-type-tile:focus-visible,
.tp-swatch:focus-visible,
.tp-upload-btn:focus-visible {
    outline: 2px solid var(--flyer-accent);
    outline-offset: 2px;
}

.tp-upload-btn {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 1.5px dashed var(--flyer-border);
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--flyer-text-muted);
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.tp-upload-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tp-upload-btn:hover:not(.tp-upload-btn--done) {
    border-color: var(--flyer-text-muted);
    background: var(--flyer-surface-hover, #F9FAFB);
}

.tp-upload-btn--done {
    border: 1.5px solid var(--flyer-accent);
    background: var(--flyer-accent-light);
    font-weight: 600;
    color: var(--flyer-accent);
}

/* Inputs */
.tp-input {
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    padding: 0 16px;
    border: 1px solid var(--flyer-border);
    border-radius: 10px;
    outline: none;
    background: var(--campaigns-input-bg);
    font-family: inherit;
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--flyer-text);
    transition: border-color 0.12s;
}

.tp-input::placeholder { color: var(--flyer-text-muted); }
.tp-input:focus { border-color: var(--flyer-accent); }
.tp-input--invalid,
.tp-input--invalid:focus { border-color: var(--tp-danger); }

.tp-field-error {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--tp-danger);
}

.tp-field-error:empty { display: none; }

.tp-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--flyer-text-muted);
}

.tp-status-line--error { color: var(--tp-danger); }

/* Preview pane */
.tp-editor-preview {
    order: 1;
    flex: 0 1 50%;   /* half each, as before; gives way to the form's 380px on narrower windows */
    min-width: 0;
    display: flex;
    overflow: hidden;
    background: var(--campaigns-pane-bg);
}

.tp-preview-stack {
    margin: auto;
    box-sizing: border-box;
    max-height: 100%;
    min-height: 0;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* The wide button under the form */
.tp-editor-footer {
    flex-shrink: 0;
    padding: 16px 42px 20px;
    border-top: 1px solid var(--flyer-border);
    background: var(--campaigns-modal-bg);
}

.tp-publish-btn {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: var(--flyer-accent);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
    cursor: pointer;
    transition: background 150ms ease, opacity 150ms ease;
}

.tp-publish-btn:hover:not(:disabled) { opacity: 0.88; }

.tp-publish-btn:disabled {
    background: var(--flyer-border);
    color: var(--flyer-text-muted);
    cursor: default;
}

/* Discard changes? */
.tp-discard {
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    border-radius: 20px;
    background: var(--flyer-surface);
    box-shadow: var(--campaigns-card-shadow, 0px 4px 6px -1px rgba(0, 0, 0, 0.05), 0px 20px 50px -12px rgba(0, 0, 0, 0.15));
    text-align: left;
    animation: coupon-fade-up 0.2s ease both;
}

.tp-discard-text { padding: 28px 28px 20px; }

.tp-discard-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--flyer-text);
}

.tp-discard-body { margin: 0; font-size: 15px; line-height: 1.55; color: var(--flyer-text-secondary); }

.tp-discard-actions { display: flex; gap: 10px; padding: 0 28px 28px; }

.tp-discard-keep,
.tp-discard-go {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.tp-discard-keep { border: 1px solid var(--flyer-border); background: transparent; color: var(--flyer-text); }
.tp-discard-keep:hover { background: var(--flyer-surface-hover, #F9FAFB); }
.tp-discard-go { border: none; background: #DC2626; color: #FFFFFF; }
.tp-discard-go:hover { filter: brightness(0.9); }

/* ─── Phone mockup (fixed light colors, like the real tracking page) ─── */
/* Drawn at an iPhone's 390 × 844 and zoomed to the pane's height
   (TrackingCampaignsUI.fitPhone), so it keeps a real phone's proportions;
   the map takes whatever the sheet leaves. */
.tp-phone {
    width: 390px;
    height: 844px;
    box-sizing: border-box;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 14px 0 0;
    border-radius: 55px;
    background: #FFFFFF;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.10), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: coupon-fade-up 0.4s ease 0.15s both;
}

.tp-phone-island {
    display: flex;
    justify-content: center;
    padding-bottom: 8px;
}

.tp-phone-island span {
    width: 100px;
    height: 28px;
    border-radius: 99px;
    background: #0A0A0A;
}

.tp-phone-store {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}

.tp-phone-store-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #F4F4F8;
    border-radius: 62px;
    background: #F4F4F8;
    color: #737373;
}

.tp-phone-store-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 16px;
    font-weight: 500;
    color: #0A0A0A;
}

.tp-phone-help {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 99px;
    background: #F4F4F8;
    color: #737373;
}

.tp-phone-help span {
    font-size: 14px;
    font-weight: 500;
}

.tp-phone > * { flex-shrink: 0; }

.tp-phone > .tp-phone-map {
    flex: 1 1 auto;
    min-height: 0;
}

.tp-phone-map {
    position: relative;
    overflow: hidden;
    background: #F0F4F0;
}

.tp-phone-map-art {
    position: absolute;
    inset: 0;
}

/* Strokes keep their pixel width however the map is stretched. */
.tp-phone-map-art path { vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.tp-map-park { fill: #D7EBD2; }
.tp-map-casing path { stroke: #DDE3DA; }
.tp-map-street path { stroke: #FFFFFF; }
.tp-map-route { stroke: #0A0A0A; }

.tp-phone-driver-pin {
    position: absolute;
    top: 24%;
    left: 55%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    border-radius: 99px;
    background: #1A1A1A;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: #FFFFFF;
}

.tp-phone-dest-pin {
    position: absolute;
    top: calc(70% - 34px);   /* the tip on the route's end */
    left: calc(25% - 14px);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-45deg);
    border-radius: 50% 50% 50% 0;
    background: #0A0A0A;
}

.tp-phone-dest-pin span {
    width: 8px;
    height: 8px;
    border-radius: 99px;
    background: #FFFFFF;
}

.tp-phone-map-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tp-phone-map-controls div {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #FFFFFF;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    color: #737373;
}

.tp-phone-sheet {
    position: relative;
    z-index: 1;
    margin-top: -20px;
    border-radius: 28px 28px 0 0;
    background: #FFFFFF;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
}

.tp-phone-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
}

.tp-phone-handle span {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #D4D4D4;
}

.tp-phone-status {
    padding: 4px 16px 10px;
    text-align: center;
}

.tp-phone-status-title {
    font-size: 18px;
    font-weight: 700;
    color: #0A0A0A;
}

.tp-phone-status-sub {
    margin-top: 2px;
    font-size: 14px;
    font-weight: 400;
    color: #525252;
}

.tp-phone-progress {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.tp-phone-progress span {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: #E5E5E5;
}

.tp-phone-progress span.tp-phone-progress--on { background: #008062; }

.tp-phone-driver {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px 14px;
}

.tp-phone-avatar {
    position: relative;
    flex-shrink: 0;
}

.tp-phone-avatar-circle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 99px;
    background: #E5E5E5;
    color: #999999;
}

.tp-phone-rating {
    position: absolute;
    bottom: -8px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    transform: translateX(-50%);
    white-space: nowrap;
    border-radius: 99px;
    background: #F5F5F5;
    font-size: 12px;
    font-weight: 600;
    color: #0A0A0A;
}

.tp-phone-rating span {
    font-size: 11px;
    color: #F59E0B;
}

.tp-phone-driver-text { flex: 1; }

.tp-phone-driver-name {
    font-size: 16px;
    font-weight: 600;
    color: #0A0A0A;
}

.tp-phone-driver-role {
    font-size: 15px;
    font-weight: 400;
    color: #737373;
}

.tp-phone-driver-actions {
    display: flex;
    gap: 8px;
}

.tp-phone-driver-actions div {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 99px;
    background: #F4F4F8;
    color: #0A0A0A;
}

.tp-phone-ad { padding: 4px 16px 12px; }

.tp-phone-subscribe {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 16px 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: #0A3D2C;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
}

.tp-phone-home {
    display: flex;
    justify-content: center;
    padding: 6px 0 10px;
    background: #FFFFFF;
}

.tp-phone-home span {
    width: 120px;
    height: 4px;
    border-radius: 99px;
    background: #E0E0E0;
}

/* ─── Dialogs (reference: header / body / footer) ─── */
.tp-dialog {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    background: var(--campaigns-modal-bg);
    box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.05), 0px 20px 50px -12px rgba(0, 0, 0, 0.15);
    animation: coupon-fade-up 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tp-dialog--sm { width: min(400px, calc(100vw - 32px)); }
.tp-dialog--lg { width: min(600px, calc(100vw - 32px)); }

.tp-dialog-head {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--flyer-border);
}

.tp-dialog-title {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--flyer-text);
}

.tp-dialog-subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: var(--flyer-text-muted);
}

.tp-dialog-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 99px;
    background: transparent;
    color: var(--flyer-text-muted);
    cursor: pointer;
}

.tp-dialog-close:hover { background: var(--flyer-close-hover); }
/* Level with the title's first line, a subtitle or not. */
.tp-dialog-head .tp-dialog-close { margin-top: -4px; }

.tp-dialog-body {
    min-height: 0;
    overflow-y: auto;
    padding: 20px 32px;
}

.tp-dialog-text {
    margin: 0;
    font-size: 15px;
    line-height: 150%;
    color: var(--flyer-text-muted);
}

.tp-dialog-text strong {
    font-weight: 600;
    color: var(--flyer-text);
}

.tp-dialog-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 16px 32px;
    border-top: 1px solid var(--flyer-border);
}

.tp-dialog-footer-end {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.tp-dialog-btn,
a.tp-dialog-btn {
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    border: 1px solid var(--flyer-border);
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    color: var(--flyer-text-secondary);
    cursor: pointer;
}

.tp-dialog-btn:not(.tp-dialog-btn--primary):not(:disabled):hover { background: var(--flyer-surface-hover); }

.tp-dialog-btn--primary,
a.tp-dialog-btn--primary,
a.tp-dialog-btn--primary:hover,
a.tp-dialog-btn--primary:focus {
    padding: 0 24px;
    border: none;
    background: var(--flyer-accent);
    font-weight: 600;
    text-decoration: none;
    color: #FFFFFF;
}

.tp-dialog-btn:disabled { opacity: 0.4; cursor: default; }
.tp-dialog-btn:focus-visible,
.tp-dialog-close:focus-visible { outline: 2px solid var(--flyer-accent); outline-offset: 2px; }

/* Tracking page settings: laid out as SMS settings (.sms-dialog--settings) */
.tp-dialog--settings { width: min(540px, calc(100vw - 32px)); }
.tp-dialog--settings .tp-dialog-head { padding-bottom: 16px; border-bottom: none; }
.tp-dialog-body.tp-settings-body { padding: 4px 32px 20px; }

.tp-settings-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    color: var(--flyer-text-muted);
    cursor: pointer;
}

.tp-settings-row:focus-visible { outline: 2px solid var(--flyer-accent); outline-offset: 2px; border-radius: 8px; }

.tp-settings-row-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--campaigns-chip-bg, #F4F4F8);
    color: var(--flyer-text-muted);
}

.tp-settings-row-text { flex: 1; min-width: 0; }

.tp-settings-row-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--flyer-text);
}

.tp-settings-row-sub {
    margin-top: 2px;
    font-size: 15px;
    color: var(--flyer-text-muted);
}

/* Reorder */
.tp-reorder-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--flyer-border);
    background: var(--campaigns-modal-bg);
}

.tp-reorder-row .tp-status-dot {
    width: 8px;
    height: 8px;
}

.tp-reorder-handle {
    display: flex;
    color: var(--flyer-text-muted);
    cursor: grab;
}

.tp-reorder-handle:active { cursor: grabbing; }

.tp-reorder-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--flyer-text);
}

.tp-reorder-ghost { opacity: 0.4; }

.tp-reorder-moves {
    display: flex;
    gap: 4px;
}

.tp-reorder-move {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--flyer-border);
    border-radius: 8px;
    background: transparent;
    color: var(--flyer-text-muted);
    cursor: pointer;
}

.tp-reorder-move:disabled { opacity: 0.35; cursor: default; }

.tp-reorder-empty {
    padding: 8px 0;
    font-size: 15px;
    color: var(--flyer-text-muted);
}

/* Image picker */
.tp-dialog-body.tp-image-body { height: min(56vh, 520px); }   /* fixed: the images loading in never resize the dialog */

.tp-image-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.tp-image-skel {
    aspect-ratio: 1;
    border-radius: 12px;
    background: var(--flyer-border);
    animation: flyer-order-pulse 1.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .tp-image-skel { animation: none; opacity: 0.6; }
}

.tp-image-tile {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    overflow: hidden;
    border: 2.5px solid transparent;
    border-radius: 12px;
    background: var(--campaigns-chip-bg);
    cursor: pointer;
    transition: border-color 150ms ease;
}

.tp-image-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tp-image-tile--active { border-color: var(--flyer-accent); }
.tp-image-tile:focus-visible { outline: 2px solid var(--flyer-accent); outline-offset: 2px; }

.tp-image-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 99px;
    background: var(--flyer-accent);
    color: #FFFFFF;
}

/* Bootstrap's input[type="file"] { display: block } outranks a lone class. */
.campaigns-settings input.tp-file-input { display: none; }

/* ─── Narrow windows ─── */
@media (max-width: 1000px) {
    .tp-editor-preview { display: none; }
    .tp-detail-preview { display: none; }
    .tp-detail-head    { padding-right: 80px; }   /* clear of the ✕ */
    .tp-editor-main    { flex-basis: 100%; min-width: 0; border-left: none; }
}

@media (max-width: 720px) {
    .tp-editor-fields  { padding: 20px 16px 32px; }
    .tp-editor-footer  { padding: 16px; }
    .tp-type-grid      { grid-template-columns: repeat(3, 1fr); }
    .tp-card-row       { flex-direction: column; }
    .tp-detail-head    { padding: 24px 80px 16px 20px; }
    .tp-detail-body    { padding: 0 20px 8px; }
    .tp-detail-actions { padding: 12px 20px 20px; }
    .tp-detail-stat-value { font-size: 24px; }
}
