/**
 * BuzzBot Design System (ds-*)
 *
 * One shared layer extracted from Orders, Tasks, Audience and Settings, loaded on every page.
 * Classes are `ds-*`, tokens `--ds-*`: nothing here touches existing page styles.
 *
 * Themes: light on :root; dark under [data-bs-theme="dark"] (Metronic, app-wide) or
 * [data-ds-theme="dark"] (any subtree). Component rules only read tokens — never a literal color.
 *
 * Reference: /design-system · Docs: templates/components/ds/README.md
 * Twig: templates/components/ds/ · JS: public/js/buzzbot_ds.js (window.BbDs)
 *
 *  1. Tokens (light, dark)       9. Popover, action menu, select menu
 *  2. Base, focus, utilities    10. Table, selection, list cards, board
 *  3. Tones                     11. Badge, status, tag, due, avatar, person
 *  4. Layout, breadcrumb        12. Feedback: empty, alert, banner, toast, tooltip
 *  5. Panel, card               13. Progress, spinner, skeleton, loading
 *  6. KPI, icon tile            14. Pager, stepper, timeline
 *  7. Buttons, dock             15. Forms
 *  8. Segmented, tabs, toolbar  16. Overlays (modal, confirm, drawer)
 *                               17. Content patterns (divider, rules, date range, charts,
 *                                   rating, image input, chat, WhatsApp preview, tag input,
 *                                   code, notification, presence, media grid)
 *                               18. Responsive and touch
 */

/* ── 1. Tokens ─────────────────────────────────────────────────────────── */
/* Theme-independent: type, space, shape, motion, layers */
:root {
    --ds-font: Inter, Tajawal, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ds-fs-display: 24px;
    --ds-fs-metric: 22px;
    --ds-fs-title: 18px;
    --ds-fs-heading: 16px;
    --ds-fs-body-lg: 14px;
    --ds-fs-body: 13px;
    --ds-fs-small: 12px;
    --ds-fs-caption: 11px;
    --ds-fs-micro: 10px;
    --ds-fw-regular: 400;
    --ds-fw-medium: 500;
    --ds-fw-semibold: 600;
    --ds-fw-bold: 700;
    --ds-fw-heavy: 800;
    --ds-tracking-caps: 0.04em;
    --ds-tracking-tight: -0.01em;
    --ds-tracking-tighter: -0.02em;

    /* Icon sizes (Iconsax is a font: an icon's size is its font-size) */
    --ds-icon-xs: 13px;
    --ds-icon-sm: 16px;
    --ds-icon-md: 18px;
    --ds-icon-lg: 22px;
    --ds-icon-xl: 28px;

    --ds-space-1: 4px;
    --ds-space-2: 8px;
    --ds-space-3: 12px;
    --ds-space-4: 16px;
    --ds-space-5: 20px;
    --ds-space-6: 24px;
    --ds-space-8: 32px;
    --ds-space-12: 48px;

    --ds-radius-xs: 6px;
    --ds-radius-sm: 8px;
    --ds-radius-md: 10px;
    --ds-radius-lg: 12px;
    --ds-radius-xl: 16px;
    --ds-radius-pill: 999px;

    /* Targets: 32px minimum for anything clickable (Fitts's law; WCAG 2.5.8 asks 24px) */
    --ds-control-sm: 32px;
    --ds-control-md: 38px;
    --ds-control-lg: 44px;

    /* Feedback inside the 400ms Doherty threshold */
    --ds-ease: cubic-bezier(0.2, 0, 0, 1);
    --ds-dur-fast: 0.12s;
    --ds-dur: 0.18s;
    --ds-dur-slow: 0.22s;

    /* Layers (Metronic drawers ~1050, legacy inbox modal 9999) */
    --ds-z-popover: 200;
    --ds-z-dock: 1055;
    --ds-z-drawer: 1080;
    --ds-z-modal: 10050;
    --ds-z-confirm: 10150;
    --ds-z-float: 10200;
    --ds-z-toast: 10300;
}

/*
 * Colors (WCAG 2.1 AA, checked by tests/DesignSystem/DesignSystemContrastTest.php):
 * text ≥4.5:1 on the surfaces it sits on; control boundaries, focus, state and chart marks ≥3:1.
 * --ds-text-subtle is the one exception: placeholders of disabled fields and decoration only.
 */
:root,
[data-bs-theme="light"],
[data-ds-theme="light"] {
    /* Brand: --ds-brand is a fill (white text on it); --ds-brand-text is brand-colored text, focus and borders */
    --ds-brand: #7239EA;
    --ds-brand-hover: #5A2DBA;
    --ds-brand-strong: #5014D0;
    --ds-brand-text: #7239EA;
    --ds-brand-soft: rgba(114, 57, 234, 0.08);
    --ds-brand-softer: rgba(114, 57, 234, 0.04);
    --ds-brand-tint: rgba(114, 57, 234, 0.12);
    --ds-brand-line: rgba(114, 57, 234, 0.35);
    --ds-bubble-agent: #312E5C;
    --ds-bubble-agent-soft: #3D3A6D;

    --ds-text: #181C32;
    --ds-text-2: #3F4254;
    --ds-text-3: #5E6278;
    --ds-text-muted: #696D82;
    --ds-text-subtle: #A1A5B7;
    --ds-text-on-brand: #FFFFFF;

    --ds-ground: #F7F8FA;
    --ds-surface: #FFFFFF;
    --ds-surface-raised: #FFFFFF;
    --ds-surface-subtle: #FAFAFA;
    --ds-surface-muted: #F9FAFB;
    --ds-surface-sunken: #F1F1F4;
    --ds-surface-table-head: #F9F9F9;
    --ds-surface-row-hover: #FAFBFC;

    /* Lines: --ds-border groups content (decorative); --ds-control-border outlines things you type in or toggle */
    --ds-border: #E5E7EB;
    --ds-border-strong: #D1D5DB;
    --ds-divider: #F1F1F4;
    --ds-control-border: #80859A;
    --ds-switch-off: #80859A;
    --ds-switch-thumb: #FFFFFF;

    /* Tones: base (icons, dots) · bg (tint) · text (≥4.5:1 on bg) · line (borders on bg) · graphic (bars, ≥3:1 on tracks) */
    --ds-success: #50CD89;
    --ds-success-bg: #E8FFF3;
    --ds-success-text: #127A41;
    --ds-success-line: #A3E4C1;
    --ds-success-graphic: #15803D;
    --ds-success-solid: #15803D;
    --ds-success-solid-hover: #166534;
    --ds-warning: #F59E0B;
    --ds-warning-bg: #FFF8DD;
    --ds-warning-text: #8A6100;
    --ds-warning-line: #F7DE8C;
    --ds-warning-graphic: #C2610C;
    --ds-warning-solid: #F59E0B;
    --ds-warning-solid-hover: #D97706;
    --ds-text-on-warning: #181C32;
    --ds-danger: #F1416C;
    --ds-danger-hover: #D9214E;
    --ds-danger-solid: #D9214E;
    --ds-danger-solid-hover: #B8173F;
    --ds-danger-bg: #FFF5F8;
    --ds-danger-bg-strong: #FFE2E5;
    --ds-danger-line: #F9D7E0;
    --ds-danger-text: #BE1A47;
    --ds-info: #3B82F6;
    --ds-info-bg: #EEF6FF;
    --ds-info-text: #2563EB;
    --ds-info-line: #C7DDFE;
    --ds-neutral-bg: #F1F1F4;
    --ds-neutral-text: #5E6278;

    /* Record status (Orders + Tasks): the dot / icon of .ds-status; the label stays text-colored */
    --ds-status-pending: #F59E0B;
    --ds-status-processing: #7239EA;
    --ds-status-confirmed: #5014D0;
    --ds-status-shipped: #009EF7;
    --ds-status-paid: #0D9488;
    --ds-status-delivered: #50CD89;
    --ds-status-cancelled: #F1416C;
    --ds-status-refunded: #A1A5B7;
    --ds-status-returned: #FFA800;
    --ds-status-deleted: #7E8299;
    --ds-status-in-progress: #3B82F6;
    --ds-status-solved: #22C55E;

    --ds-backdrop: rgba(15, 23, 42, 0.45);
    --ds-tooltip-bg: #181C32;
    --ds-tooltip-text: #FFFFFF;
    --ds-skeleton: #EEF0F4;
    --ds-skeleton-shine: #F7F8FA;
    --ds-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23696D82' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");

    --ds-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --ds-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --ds-shadow-brand: 0 2px 6px rgba(114, 57, 234, 0.25);
    --ds-shadow-hover: 0 4px 16px rgba(114, 57, 234, 0.08);
    --ds-shadow-menu: 0 12px 28px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
    --ds-shadow-dialog: 0 20px 48px rgba(24, 28, 50, 0.18);
    --ds-shadow-drawer: -12px 0 40px rgba(15, 23, 42, 0.16);
    --ds-shadow-drawer-rtl: 12px 0 40px rgba(15, 23, 42, 0.16);
    --ds-switch-thumb-shadow: 0 1px 2px rgba(24, 28, 50, 0.24);
    --ds-ring: 0 0 0 3px rgba(114, 57, 234, 0.12);
    --ds-ring-danger: 0 0 0 3px rgba(241, 65, 108, 0.12);

    /* Chart series, in this order (never cycled): checked for colour-blind separation; slots 3, 5 and 6 sit
       under 3:1 on white, so charts always carry a legend or direct labels */
    --ds-chart-1: #7239EA;
    --ds-chart-2: #EB6834;
    --ds-chart-3: #1BAF7A;
    --ds-chart-4: #2A78D6;
    --ds-chart-5: #EDA100;
    --ds-chart-6: #E87BA4;

    /* WhatsApp message preview: the app's own colours, so a template looks as it will on the phone */
    --ds-wa-wallpaper: #EFEAE2;
    --ds-wa-header: #FFFFFF;
    --ds-wa-bubble: #FFFFFF;
    --ds-wa-bubble-out: #D9FDD3;
    --ds-wa-text: #111B21;
    --ds-wa-meta: #667781;
    --ds-wa-link: #027EB5;
    --ds-wa-frame: #1F2937;
}

[data-bs-theme="dark"],
[data-ds-theme="dark"] {
    color-scheme: dark;

    --ds-brand: #8D53F1;
    --ds-brand-hover: #7A45EE;
    --ds-brand-strong: #C4B2FF;
    --ds-brand-text: #B8A3FF;
    --ds-brand-soft: rgba(140, 100, 255, 0.16);
    --ds-brand-softer: rgba(140, 100, 255, 0.08);
    --ds-brand-tint: rgba(140, 100, 255, 0.24);
    --ds-bubble-agent: #312E5C;
    --ds-bubble-agent-soft: #3D3A6D;
    --ds-brand-line: rgba(184, 163, 255, 0.45);

    --ds-text: #F5F5F7;
    --ds-text-2: #D4D4DC;
    --ds-text-3: #ADADBA;
    --ds-text-muted: #9A9AAB;
    --ds-text-subtle: #6E6E7E;
    --ds-text-on-brand: #FFFFFF;

    --ds-ground: #1C1C1C;
    --ds-surface: #212128;
    --ds-surface-raised: #2C2C36;
    --ds-surface-subtle: #1C1C22;
    --ds-surface-muted: #2A2A33;
    --ds-surface-sunken: #18181D;
    --ds-surface-table-head: #1C1C22;
    --ds-surface-row-hover: #26262E;

    --ds-border: #33333E;
    --ds-border-strong: #45454F;
    --ds-divider: #2A2A33;
    --ds-control-border: #808096;
    --ds-switch-off: #74748A;
    --ds-switch-thumb: #F5F5F7;

    --ds-success: #50CD89;
    --ds-success-bg: rgba(80, 205, 137, 0.14);
    --ds-success-text: #6EE7A8;
    --ds-success-line: rgba(80, 205, 137, 0.35);
    --ds-success-graphic: #50CD89;
    --ds-success-solid: #15803D;
    --ds-success-solid-hover: #166534;
    --ds-warning: #F59E0B;
    --ds-warning-bg: rgba(245, 158, 11, 0.14);
    --ds-warning-text: #FBBF24;
    --ds-warning-line: rgba(245, 158, 11, 0.35);
    --ds-warning-graphic: #F59E0B;
    --ds-warning-solid: #F59E0B;
    --ds-warning-solid-hover: #D97706;
    --ds-text-on-warning: #181C32;
    --ds-danger: #F1416C;
    --ds-danger-hover: #FF5C83;
    --ds-danger-solid: #D9214E;
    --ds-danger-solid-hover: #C81E4B;
    --ds-danger-bg: rgba(241, 65, 108, 0.12);
    --ds-danger-bg-strong: rgba(241, 65, 108, 0.2);
    --ds-danger-line: rgba(241, 65, 108, 0.35);
    --ds-danger-text: #FF8FA9;
    --ds-info: #60A5FA;
    --ds-info-bg: rgba(59, 130, 246, 0.16);
    --ds-info-text: #93C5FD;
    --ds-info-line: rgba(96, 165, 250, 0.35);
    --ds-neutral-bg: #2E2E38;
    --ds-neutral-text: #C4C4D0;

    --ds-status-pending: #F59E0B;
    --ds-status-processing: #B8A3FF;
    --ds-status-confirmed: #9F7AFF;
    --ds-status-shipped: #009EF7;
    --ds-status-paid: #0D9488;
    --ds-status-delivered: #50CD89;
    --ds-status-cancelled: #F1416C;
    --ds-status-refunded: #A1A5B7;
    --ds-status-returned: #FFA800;
    --ds-status-deleted: #8E8EA0;
    --ds-status-in-progress: #60A5FA;
    --ds-status-solved: #22C55E;

    --ds-backdrop: rgba(0, 0, 0, 0.6);
    --ds-tooltip-bg: #3A3A46;
    --ds-tooltip-text: #F5F5F7;
    --ds-skeleton: #2A2A33;
    --ds-skeleton-shine: #34343F;
    --ds-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239A9AAB' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");

    --ds-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --ds-shadow-brand: 0 2px 8px rgba(141, 83, 241, 0.45);
    --ds-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.35);
    --ds-shadow-menu: 0 12px 28px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    --ds-shadow-dialog: 0 20px 48px rgba(0, 0, 0, 0.6);
    --ds-shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.5);
    --ds-shadow-drawer-rtl: 12px 0 40px rgba(0, 0, 0, 0.5);
    --ds-switch-thumb-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --ds-ring: 0 0 0 3px rgba(184, 163, 255, 0.35);
    --ds-ring-danger: 0 0 0 3px rgba(255, 107, 139, 0.3);

    --ds-chart-1: #8D53F1;
    --ds-chart-2: #D95926;
    --ds-chart-3: #199E70;
    --ds-chart-4: #3987E5;
    --ds-chart-5: #C98500;
    --ds-chart-6: #D55181;

    --ds-wa-wallpaper: #0B141A;
    --ds-wa-header: #202C33;
    --ds-wa-bubble: #202C33;
    --ds-wa-bubble-out: #005C4B;
    --ds-wa-text: #E9EDEF;
    --ds-wa-meta: #8696A0;
    --ds-wa-link: #53BDEB;
    --ds-wa-frame: #3A3A46;
}

/*
 * Arabic: Tajawal first, one size step up (Tajawal reads smaller than Inter at the same size),
 * no letter-spacing (tracking breaks the joins between Arabic letters). Applies to the whole
 * page when <html lang="ar">, or to any element marked lang="ar" inside another language.
 */
[lang|="ar"] {
    --ds-font: Tajawal, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ds-fs-body-lg: 15px;
    --ds-fs-body: 14px;
    --ds-fs-small: 13px;
    --ds-fs-caption: 12px;
    --ds-fs-micro: 11px;
    --ds-tracking-caps: 0;
    --ds-tracking-tight: 0;
    --ds-tracking-tighter: 0;
}
[lang|="ar"]:not(html) { font-family: var(--ds-font); }

/* A themed subtree paints its own ground (overlays carry the attribute only to inherit tokens) */
[data-ds-theme]:not(.ds-modal, .ds-drawer, .ds-toast-region, .ds-tooltip) {
    background-color: var(--ds-ground);
    color: var(--ds-text);
}

/* ── 2. Base, focus, utilities ─────────────────────────────────────────── */
/* Own box model: ds layouts must not depend on a page framework's reset (zero specificity, easy to override) */
:where(.ds-page, .ds-modal, .ds-drawer, .ds-popover, .ds-menu__list, .ds-select-menu__list, .ds-toast-region, .ds-tooltip, .ds-dock,
       .ds-rules, .ds-date-range, .ds-image-input, .ds-chat, .ds-composer, .ds-wa, .ds-tag-input, .ds-code, .ds-notif, .ds-media-grid),
:where(.ds-page, .ds-modal, .ds-drawer, .ds-popover, .ds-menu__list, .ds-select-menu__list, .ds-toast-region, .ds-dock,
       .ds-rules, .ds-date-range, .ds-image-input, .ds-chat, .ds-composer, .ds-wa, .ds-tag-input, .ds-code, .ds-notif, .ds-media-grid) *,
:where(.ds-page, .ds-modal, .ds-drawer, .ds-popover, .ds-menu__list, .ds-select-menu__list, .ds-toast-region, .ds-dock,
       .ds-rules, .ds-date-range, .ds-image-input, .ds-chat, .ds-composer, .ds-wa, .ds-tag-input, .ds-code, .ds-notif, .ds-media-grid) *::before,
:where(.ds-page, .ds-modal, .ds-drawer, .ds-popover, .ds-menu__list, .ds-select-menu__list, .ds-toast-region, .ds-dock,
       .ds-rules, .ds-date-range, .ds-image-input, .ds-chat, .ds-composer, .ds-wa, .ds-tag-input, .ds-code, .ds-notif, .ds-media-grid) *::after {
    box-sizing: border-box;
}

.ds-page,
.ds-modal,
.ds-drawer,
.ds-popover,
.ds-menu__list,
.ds-select-menu__list,
.ds-toast-region,
.ds-tooltip {
    font-family: var(--ds-font);
    -webkit-font-smoothing: antialiased;
}

/* One visible focus style for every interactive ds element (inputs use border + ring instead) */
.ds-btn:focus-visible,
.ds-icon-btn:focus-visible,
.ds-chip:focus-visible,
.ds-segmented__item:focus-visible,
.ds-tabs__item:focus-visible,
.ds-filter__btn:focus-visible,
.ds-menu__item:focus-visible,
.ds-option:focus-visible,
.ds-pager__page:focus-visible,
.ds-pager__btn:focus-visible,
.ds-list-card:focus-visible,
.ds-card--interactive:focus-visible,
a.ds-kpi:focus-visible,
.ds-person__name:focus-visible,
.ds-breadcrumb a:focus-visible,
.ds-disclosure > summary:focus-visible,
.ds-dropzone:focus-within,
.ds-table tbody tr.is-clickable:focus-visible {
    outline: 2px solid var(--ds-brand-text);
    outline-offset: 2px;
}

/* Brand marks Iconsax doesn't draw: the Keenicons outline glyph, under the same <i class="iconsax" icon-name="…"> API */
.iconsax[icon-name="whatsapp"]::before,
.iconsax[icon-name="youtube"]::before { font-family: "keenicons-outline"; }
.iconsax[icon-name="whatsapp"]::before { content: "\eb33"; }
.iconsax[icon-name="youtube"]::before { content: "\eb3c"; }

.ds-overline {
    margin: 0;
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-bold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
    color: var(--ds-text-muted);
}
.ds-muted { color: var(--ds-text-muted) !important; }
.ds-tabular { font-variant-numeric: tabular-nums; }
.ds-truncate {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.ds-divider {
    height: 1px;
    margin: var(--ds-space-4) 0;
    border: 0;
    background: var(--ds-divider);
}
/* Inline meta: "24 Oct 2026 · 14:32 · WhatsApp" */
.ds-meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
    font-size: var(--ds-fs-small);
    color: var(--ds-text-muted);
}
.ds-meta > * + *::before {
    content: "·";
    margin-inline: 6px;
    color: var(--ds-text-subtle);
}
/* Table on desktop, cards on tablets and phones (same breakpoint as Orders / Tasks) */
@media (max-width: 991.98px) {
    .ds-hide-tablet { display: none !important; }
}
@media (min-width: 992px) {
    .ds-show-tablet { display: none !important; }
}
/* Scroll lock while an overlay is open; JS pads the scrollbar width to avoid a jump */
body.ds-overlay-open {
    overflow: hidden;
    padding-inline-end: var(--ds-scrollbar, 0px);
}

/* ── 3. Tones ──────────────────────────────────────────────────────────── */
/* Components read --ds-t (base), --ds-t-bg, --ds-t-text, --ds-t-line; modifiers only switch the set */
/* Defaults first (neutral badges and alerts, brand tiles and bars), modifiers after: order matters */
.ds-badge, .ds-alert, .ds-banner {
    --ds-t: var(--ds-text-muted);
    --ds-t-bg: var(--ds-neutral-bg);
    --ds-t-text: var(--ds-neutral-text);
    --ds-t-line: var(--ds-border);
}
.ds-tone-brand, .ds-badge--brand, .ds-icon-tile, .ds-alert--brand, .ds-banner--brand, .ds-progress, .ds-toast {
    --ds-t: var(--ds-brand);
    --ds-t-bg: var(--ds-brand-soft);
    --ds-t-text: var(--ds-brand-text);
    --ds-t-line: var(--ds-brand-line);
}
.ds-tone-neutral, .ds-icon-tile--neutral, .ds-progress--neutral {
    --ds-t: var(--ds-text-muted);
    --ds-t-bg: var(--ds-neutral-bg);
    --ds-t-text: var(--ds-neutral-text);
    --ds-t-line: var(--ds-border);
}
.ds-tone-success, .ds-badge--success, .ds-icon-tile--success, .ds-alert--success, .ds-banner--success, .ds-progress--success, .ds-toast--success {
    --ds-t: var(--ds-success);
    --ds-t-bg: var(--ds-success-bg);
    --ds-t-text: var(--ds-success-text);
    --ds-t-line: var(--ds-success-line);
}
.ds-tone-warning, .ds-badge--warning, .ds-icon-tile--warning, .ds-alert--warning, .ds-banner--warning, .ds-progress--warning, .ds-toast--warning {
    --ds-t: var(--ds-warning);
    --ds-t-bg: var(--ds-warning-bg);
    --ds-t-text: var(--ds-warning-text);
    --ds-t-line: var(--ds-warning-line);
}
.ds-tone-danger, .ds-badge--danger, .ds-icon-tile--danger, .ds-alert--danger, .ds-banner--danger, .ds-progress--danger, .ds-toast--danger {
    --ds-t: var(--ds-danger);
    --ds-t-bg: var(--ds-danger-bg-strong);
    --ds-t-text: var(--ds-danger-text);
    --ds-t-line: var(--ds-danger-line);
}
.ds-tone-info, .ds-badge--info, .ds-icon-tile--info, .ds-alert--info, .ds-banner--info, .ds-progress--info, .ds-toast--info {
    --ds-t: var(--ds-info);
    --ds-t-bg: var(--ds-info-bg);
    --ds-t-text: var(--ds-info-text);
    --ds-t-line: var(--ds-info-line);
}
.ds-alert--danger, .ds-banner--danger { --ds-t-bg: var(--ds-danger-bg); }

/* ── 4. Layout, breadcrumb ─────────────────────────────────────────────── */
/* Right to left. Page CSS multiplies its horizontal transforms by --ds-dir, so they mirror with the page.
   Directional icons mirror too; a phone number or a code stays as it is inside .ds-ltr. */
:root { --ds-dir: 1; }
[dir="rtl"] { --ds-dir: -1; }
[dir="ltr"] { --ds-dir: 1; }
[dir="rtl"] .iconsax[icon-name="arrow-left"],
[dir="rtl"] .iconsax[icon-name="arrow-right"],
[dir="rtl"] .iconsax[icon-name="chevron-left"],
[dir="rtl"] .iconsax[icon-name="chevron-right"],
[dir="rtl"] .iconsax[icon-name="logout-1"],
[dir="rtl"] .iconsax[icon-name="logout-2"],
[dir="rtl"] .iconsax[icon-name="login"],
[dir="rtl"] .iconsax[icon-name="login-2"],
[dir="rtl"] .iconsax[icon-name="send-1"],
[dir="rtl"] .iconsax[icon-name="send-2"] { transform: scaleX(-1); }
.ds-nowrap { white-space: nowrap; }
.ds-text-muted { color: var(--ds-text-muted); }
/* Plain code and links inside a page read on every surface */
.ds-page code:not(.ds-code code) { padding: 1px 6px; border-radius: var(--ds-radius-xs); font-size: var(--ds-fs-small); color: var(--ds-text-2); background: var(--ds-surface-sunken); }
.ds-code code { color: var(--ds-text); background: transparent; }
.ds-table a:not([class]) { color: var(--ds-brand-text); font-weight: var(--ds-fw-medium); }
.ds-table a:not([class]):hover { text-decoration: underline; }

/* Page frame (layouts/app.html.twig). The shell's content container owns the gutters and the gap under the header:
   30px on desktop, 20px below 992px, 24px / 16px on top. Nothing inside a page adds its own. */
.ds-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0 0 var(--ds-space-2);
    font-size: var(--ds-fs-body);
    color: var(--ds-text-2);
}
.ds-page--narrow { max-width: 760px; margin-inline: auto; }
.ds-page--wide { max-width: 1200px; margin-inline: auto; }
.ds-page-crumb { margin-bottom: var(--ds-space-2); }
.ds-page-alerts { display: flex; flex-direction: column; gap: var(--ds-space-2); margin-bottom: var(--ds-space-4); }
.ds-page-kpis { margin-bottom: var(--ds-space-4); }
/* A screen that fills the window keeps its own box tree (layouts/workspace.html.twig) */
.ds-workspace { display: contents; }
/* Screens not rebuilt yet: the old title and breadcrumb markup in the frame's title slot */
.ds-page-header .page-heading {
    margin: 0 !important;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-display) !important;
    font-weight: var(--ds-fw-bold) !important;
    line-height: 1.25;
    letter-spacing: var(--ds-tracking-tight);
    color: var(--ds-text) !important;
}
.ds-page-header .breadcrumb {
    margin: var(--ds-space-1) 0 0 !important;
    padding: 0 !important;
    font-size: var(--ds-fs-small) !important;
    font-weight: var(--ds-fw-medium) !important;
    color: var(--ds-text-muted);
}
.ds-page-header .breadcrumb .breadcrumb-item,
.ds-page-header .breadcrumb .breadcrumb-item a,
.ds-page-header .breadcrumb .text-muted { color: var(--ds-text-muted) !important; }
.ds-page-header .breadcrumb .breadcrumb-item a:hover { color: var(--ds-brand-text) !important; }
.ds-page[data-ds-theme] { padding-top: var(--ds-space-4); border-radius: var(--ds-radius-lg); }
/* Pages that draw their own title hide the Metronic toolbar */
body:has(.ds-page[data-ds-own-header]) #kt_app_toolbar,
body:has(.ds-page[data-ds-own-header]) .app-toolbar {
    display: none !important;
}
.ds-stack {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    min-width: 0;
}
.ds-stack--tight { gap: 6px; }
.ds-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--ds-space-3) var(--ds-space-4);
    margin-bottom: var(--ds-space-4);
}
.ds-page-header:has(+ .ds-page-subnav) { margin-bottom: var(--ds-space-3); }
.ds-page-header__text { min-width: 0; }
.ds-page-header__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
}
.ds-page-subnav { margin-bottom: var(--ds-space-4); min-width: 0; }
.ds-page-title {
    margin: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-display);
    font-weight: var(--ds-fw-bold);
    line-height: 1.25;
    letter-spacing: var(--ds-tracking-tight);
    color: var(--ds-text);
    text-wrap: balance;
}
.ds-page-subtitle {
    margin: 6px 0 0;
    font-size: var(--ds-fs-body-lg);
    font-weight: var(--ds-fw-medium);
    line-height: 1.45;
    color: var(--ds-text-muted);
}
.ds-page-header .ds-breadcrumb { margin-bottom: 6px; }
@media (max-width: 991.98px) {
    .ds-page { padding: 0 14px 24px; }
}
@media (max-width: 575.98px) {
    .ds-page { padding: 10px 10px 20px; }
}

.ds-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-text-muted);
}
.ds-breadcrumb li { display: inline-flex; align-items: center; min-width: 0; }
.ds-breadcrumb li + li::before {
    content: "/";
    margin-inline: 8px;
    color: var(--ds-text-subtle);
}
.ds-breadcrumb a { color: var(--ds-text-3); text-decoration: none; border-radius: 4px; }
.ds-breadcrumb a:hover { color: var(--ds-brand-text); }
.ds-breadcrumb [aria-current="page"] { color: var(--ds-text); font-weight: var(--ds-fw-semibold); }

/* ── 5. Panel, card ────────────────────────────────────────────────────── */
.ds-panel {
    min-width: 0;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-xs);
    color: var(--ds-text-2);
}
.ds-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--ds-space-3) var(--ds-space-4);
    padding: var(--ds-space-5) var(--ds-space-5) 0;
}
.ds-panel__header-text { min-width: 0; }
.ds-panel__title {
    margin: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-heading);
    font-weight: var(--ds-fw-bold);
    line-height: 1.3;
    color: var(--ds-text);
}
.ds-panel__subtitle {
    margin: 4px 0 0;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: 1.45;
    color: var(--ds-text-muted);
}
.ds-panel__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
}
.ds-panel__bar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5) var(--ds-space-3);
}
.ds-panel__body {
    min-width: 0;
    padding: var(--ds-space-4) var(--ds-space-5) var(--ds-space-5);
}
.ds-panel__bar + .ds-panel__body { padding-top: var(--ds-space-2); }
.ds-panel__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    padding: 14px var(--ds-space-5);
    border-top: 1px solid var(--ds-divider);
}
@media (max-width: 575.98px) {
    .ds-panel__header { padding: var(--ds-space-4) var(--ds-space-4) 0; }
    .ds-panel__bar { padding: var(--ds-space-3) var(--ds-space-4); }
    .ds-panel__body { padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4); }
}

/* Card: one item in a grid (templates, automations, integrations) */
.ds-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: var(--ds-space-4);
}
.ds-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    color: var(--ds-text-2);
    text-decoration: none;
    transition: border-color var(--ds-dur) ease, box-shadow var(--ds-dur) ease;
}
.ds-card--interactive { cursor: pointer; }
.ds-card--interactive:hover {
    border-color: var(--ds-brand-line);
    box-shadow: var(--ds-shadow-hover);
}
.ds-card:has(.ds-menu.is-open) { overflow: visible; z-index: 40; }
.ds-card__media {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    overflow: hidden;
    background: var(--ds-surface-sunken);
    color: var(--ds-text-subtle);
    font-size: var(--ds-icon-xl);
}
.ds-card__media img { width: 100%; height: 100%; object-fit: cover; }
.ds-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: var(--ds-space-4);
}
.ds-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-2);
    min-width: 0;
}
.ds-card__title {
    margin: 0;
    font-size: var(--ds-fs-body-lg);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.35;
    color: var(--ds-text);
}
.ds-card__text {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: var(--ds-fs-body);
    line-height: 1.5;
    color: var(--ds-text-3);
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.ds-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-2);
    padding: 10px var(--ds-space-4);
    border-top: 1px solid var(--ds-divider);
}

/* ── 6. KPI, icon tile ─────────────────────────────────────────────────── */
.ds-kpi-grid {
    --ds-kpi-cols: 4;
    --ds-kpi-gap: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(max(168px, calc((100% - (var(--ds-kpi-cols) - 1) * var(--ds-kpi-gap)) / var(--ds-kpi-cols))), 1fr));
    gap: var(--ds-kpi-gap);
    margin-bottom: var(--ds-space-6);
}
@media (max-width: 575.98px) {
    .ds-kpi-grid {
        --ds-kpi-gap: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.ds-kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 110px;
    padding: 18px var(--ds-space-4) 14px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    font-family: var(--ds-font);
    text-align: start;
    text-decoration: none;
    transition: border-color var(--ds-dur) ease, box-shadow var(--ds-dur) ease;
}
a.ds-kpi, button.ds-kpi { cursor: pointer; }
a.ds-kpi:hover, button.ds-kpi:hover {
    border-color: var(--ds-brand-line);
    box-shadow: var(--ds-shadow-hover);
}
.ds-kpi__head {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    min-width: 0;
    margin-bottom: 6px;
}
.ds-kpi__label {
    min-width: 0;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
    color: var(--ds-text-muted);
}
/* One KPI across several currencies */
.ds-kpi__values { display: flex; flex-wrap: wrap; gap: 2px var(--ds-space-3); font-size: var(--ds-fs-title); }
.ds-kpi__values small { font-size: var(--ds-fs-small); font-weight: var(--ds-fw-medium); color: var(--ds-text-muted); }
.ds-kpi__value {
    font-size: var(--ds-fs-metric);
    font-weight: var(--ds-fw-heavy);
    line-height: 1.15;
    letter-spacing: var(--ds-tracking-tighter);
    color: var(--ds-text);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.ds-kpi__sub {
    margin-top: 2px;
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-text-muted);
}
.ds-kpi__trend { font-weight: var(--ds-fw-bold); }
.ds-kpi__trend.is-up { color: var(--ds-success-text); }
.ds-kpi__trend.is-down { color: var(--ds-danger-text); }

.ds-icon-tile {
    --ds-tile-size: 32px;
    width: var(--ds-tile-size);
    height: var(--ds-tile-size);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-t-bg);
    color: var(--ds-t);
    font-size: var(--ds-icon-md);
}
.ds-icon-tile i { color: inherit; }

/* ── 7. Buttons, dock ──────────────────────────────────────────────────── */
.ds-btn {
    --ds-btn-bg: var(--ds-surface);
    --ds-btn-fg: var(--ds-text-3);
    --ds-btn-line: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--ds-control-md);
    min-height: var(--ds-control-md);
    margin: 0;
    padding: 0 var(--ds-space-4);
    border: 1px solid var(--ds-btn-line);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-btn-bg);
    color: var(--ds-btn-fg);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none !important;
    cursor: pointer;
    user-select: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    transition: background-color var(--ds-dur-fast) ease, border-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ds-btn:hover,
.ds-btn:focus-visible { color: var(--ds-btn-fg); }
.ds-btn > i { font-size: var(--ds-icon-sm); line-height: 1; color: inherit; }
.ds-btn:disabled,
.ds-btn.is-disabled,
.ds-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.ds-btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    opacity: 1;
}
.ds-btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ds-btn-fg);
    border-inline-end-color: transparent;
    border-radius: 50%;
    animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

.ds-btn--primary {
    --ds-btn-bg: var(--ds-brand);
    --ds-btn-fg: var(--ds-text-on-brand);
    --ds-btn-line: var(--ds-brand);
    box-shadow: var(--ds-shadow-brand);
}
.ds-btn--primary:hover { --ds-btn-bg: var(--ds-brand-hover); --ds-btn-line: var(--ds-brand-hover); }
.ds-btn--secondary {
    --ds-btn-line: var(--ds-border);
}
.ds-btn--secondary:hover {
    --ds-btn-bg: var(--ds-surface-muted);
    --ds-btn-fg: var(--ds-text);
    --ds-btn-line: var(--ds-border-strong);
}
.ds-btn--soft {
    --ds-btn-bg: var(--ds-brand-soft);
    --ds-btn-fg: var(--ds-brand-text);
}
.ds-btn--soft:hover { --ds-btn-bg: var(--ds-brand-tint); }
.ds-btn--ghost {
    --ds-btn-bg: transparent;
}
.ds-btn--ghost:hover { --ds-btn-bg: var(--ds-surface-sunken); --ds-btn-fg: var(--ds-text); }
.ds-btn--danger {
    --ds-btn-bg: var(--ds-danger-bg);
    --ds-btn-fg: var(--ds-danger-text);
    --ds-btn-line: var(--ds-danger-line);
}
.ds-btn--danger:hover { --ds-btn-bg: var(--ds-danger-bg-strong); --ds-btn-line: var(--ds-danger); }
.ds-btn--danger-solid {
    --ds-btn-bg: var(--ds-danger-solid);
    --ds-btn-fg: var(--ds-text-on-brand);
    --ds-btn-line: var(--ds-danger-solid);
}
.ds-btn--danger-solid:hover { --ds-btn-bg: var(--ds-danger-solid-hover); --ds-btn-line: var(--ds-danger-solid-hover); }

.ds-btn--sm {
    height: var(--ds-control-sm);
    min-height: var(--ds-control-sm);
    padding: 0 var(--ds-space-3);
    font-size: var(--ds-fs-small);
}
.ds-btn--lg {
    height: var(--ds-control-lg);
    min-height: var(--ds-control-lg);
    padding: 0 20px;
    border-radius: var(--ds-radius-md);
    font-size: var(--ds-fs-body-lg);
}
.ds-btn--block { width: 100%; }
.ds-btn--icon { width: var(--ds-control-md); padding: 0; }
.ds-btn--icon.ds-btn--sm { width: var(--ds-control-sm); }
.ds-btn-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2); }

.ds-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ds-control-sm);
    height: var(--ds-control-sm);
    min-width: var(--ds-control-sm);
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-muted);
    font-size: var(--ds-icon-md);
    line-height: 1;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: background-color var(--ds-dur-fast) ease, border-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ds-icon-btn i { color: inherit; }
.ds-icon-btn svg { display: block; width: 14px; height: 14px; pointer-events: none; }
.ds-icon-btn:hover,
.ds-icon-btn[aria-expanded="true"] {
    background: var(--ds-surface-sunken);
    color: var(--ds-text);
}
.ds-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ds-icon-btn--outlined {
    background: var(--ds-surface);
    border-color: var(--ds-border);
}
.ds-icon-btn--outlined:hover,
.ds-icon-btn--outlined[aria-expanded="true"] { border-color: var(--ds-border-strong); }
.ds-icon-btn--danger:hover { background: var(--ds-danger-bg); color: var(--ds-danger-text); }

/* Phone dock for the page's primary action */
.ds-dock { display: none; }
@media (max-width: 991.98px) {
    .ds-dock {
        position: fixed;
        inset: auto 0 0;
        z-index: var(--ds-z-dock);
        display: flex;
        gap: 10px;
        padding-block: 12px max(12px, env(safe-area-inset-bottom, 0px)); padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
        background: var(--ds-surface);
        border-top: 1px solid var(--ds-border);
        box-shadow: var(--ds-shadow-menu);
    }
    .ds-dock .ds-btn {
        flex: 1 1 auto;
        height: 48px;
        border-radius: var(--ds-radius-lg);
        font-size: var(--ds-fs-body-lg);
    }
    body:has(.ds-dock) { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important; }
    body.ds-overlay-open .ds-dock { visibility: hidden; }
    .ds-hide-docked { display: none !important; }
}

/* ── 8. Segmented, tabs, toolbar, chips ────────────────────────────────── */
.ds-segmented {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    min-width: 0;
    min-height: var(--ds-control-md);
    padding: 3px;
    background: var(--ds-surface-sunken);
    border-radius: var(--ds-radius-md);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.ds-segmented::-webkit-scrollbar { display: none; }
.ds-segmented__item {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: calc(var(--ds-control-md) - 6px);
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-3);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ds-segmented__item:hover { color: var(--ds-text); }
.ds-segmented__item.is-active,
.ds-segmented__item.active,
.ds-segmented__item[aria-selected="true"],
.ds-segmented__item[aria-pressed="true"],
.ds-segmented__item[aria-current="page"],
.ds-segmented__item:has(> input:checked) {
    background: var(--ds-surface-raised);
    color: var(--ds-text);
    box-shadow: var(--ds-shadow-sm), inset 0 0 0 1px var(--ds-control-border);
}
.ds-segmented__item > input { position: absolute; opacity: 0; pointer-events: none; }
.ds-segmented__item:has(> input:focus-visible) { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }
.ds-segmented__item > i { font-size: var(--ds-icon-sm); line-height: 1; }
.ds-segmented__count,
.ds-tabs__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--ds-border);
    color: var(--ds-text-3);
    font-size: var(--ds-fs-micro);
    font-weight: var(--ds-fw-bold);
    font-variant-numeric: tabular-nums;
}
.ds-segmented__item.is-active .ds-segmented__count,
.ds-segmented__item[aria-selected="true"] .ds-segmented__count,
.ds-tabs__item[aria-selected="true"] .ds-tabs__count,
.ds-tabs__item.is-active .ds-tabs__count {
    background: var(--ds-brand-tint);
    color: var(--ds-brand-text);
}
.ds-segmented--sm .ds-segmented__item { padding: 0 12px; font-size: var(--ds-fs-small); }
.ds-segmented--brand .ds-segmented__item.is-active,
.ds-segmented--brand .ds-segmented__item:has(> input:checked) { color: var(--ds-brand-text); }
.ds-segmented--block { display: flex; width: 100%; }
.ds-segmented--block .ds-segmented__item { flex: 1 1 0; }
@media (max-width: 991.98px) {
    .ds-segmented--fill-tablet { display: flex; width: 100%; }
    .ds-segmented--fill-tablet .ds-segmented__item { flex: 1 1 auto; }
}

/* Underline tabs: switch content inside a panel or a profile */
.ds-tabs {
    display: flex;
    gap: var(--ds-space-5);
    min-width: 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--ds-border);
    scrollbar-width: none;
}
.ds-tabs::-webkit-scrollbar { display: none; }
.ds-tabs__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-height: var(--ds-control-md);
    margin: 0 0 -1px;
    padding: 6px 2px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--ds-text-3);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    white-space: nowrap;
    text-decoration: none !important;
    cursor: pointer;
}
.ds-tabs__item:hover { color: var(--ds-text); }
.ds-tabs__item.is-active,
.ds-tabs__item[aria-selected="true"],
.ds-tabs__item[aria-current="page"] {
    border-bottom-color: var(--ds-brand);
    color: var(--ds-text);
}
.ds-tab-panel[hidden] { display: none; }

.ds-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1 1 320px;
    max-width: 640px;
    min-width: 0;
    margin-inline-start: auto;
}
/* Beside tabs it goes to the far end. Alone in the bar it starts under the title, in either direction. */
.ds-toolbar:only-child { margin-inline-start: 0; }
.ds-search {
    position: relative;
    flex: 1 1 200px;
    min-width: 0;
}
.ds-search__icon {
    position: absolute;
    top: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    color: var(--ds-text-muted);
    font-size: var(--ds-icon-sm);
    line-height: 1;
    pointer-events: none;
}
.ds-search .ds-input { padding-inline-start: 40px; }
/* The browser's clear button is bright blue in Chrome. It keeps working, drawn in our colors. */
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-inline-start: var(--ds-space-2);
    background-color: var(--ds-text-muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2 2l10 10M12 2L2 12' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2 2l10 10M12 2L2 12' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    cursor: pointer;
}
input[type="search"]::-webkit-search-cancel-button:hover { background-color: var(--ds-text); }
/* These pages draw their own button */
form:has(.bb-wa-search-clear) input[type="search"]::-webkit-search-cancel-button { display: none; }

.ds-filter { position: relative; flex-shrink: 0; }
.ds-filter__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--ds-control-md);
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text-3);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease, background-color var(--ds-dur-fast) ease;
}
.ds-filter__btn > i { font-size: var(--ds-icon-sm); color: inherit; }
.ds-filter__btn:hover,
.ds-filter__btn.is-filtered,
.ds-filter__btn[aria-expanded="true"] {
    border-color: var(--ds-brand);
    color: var(--ds-brand-text);
}
.ds-filter__btn[aria-expanded="true"] { background: var(--ds-brand-softer); }
.ds-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--ds-brand);
    color: var(--ds-text-on-brand);
    font-size: var(--ds-fs-micro);
    font-weight: var(--ds-fw-bold);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.ds-count:empty { display: none; }

.ds-chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.ds-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    min-height: var(--ds-control-sm);
    padding: 6px 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text-3);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color var(--ds-dur-fast) ease, border-color var(--ds-dur-fast) ease, color var(--ds-dur-fast) ease;
}
.ds-chip:hover {
    border-color: var(--ds-brand);
    background: var(--ds-brand-softer);
    color: var(--ds-brand-text);
}
.ds-chip.is-active,
.ds-chip[aria-pressed="true"],
.ds-chip:has(> input:checked) {
    border-color: var(--ds-brand);
    background: var(--ds-brand);
    color: var(--ds-text-on-brand);
}
.ds-chip.is-active:hover,
.ds-chip[aria-pressed="true"]:hover { border-color: var(--ds-brand-hover); background: var(--ds-brand-hover); }
.ds-chip > input { position: absolute; opacity: 0; pointer-events: none; }
/* Removable chip (selected values in a field) */
.ds-chip__remove {
    display: inline-flex;
    margin-inline-end: -4px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: var(--ds-icon-xs);
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
}
.ds-chip__remove:hover { opacity: 1; }

/* ── 9. Popover, action menu, select menu ──────────────────────────────── */
.ds-popover,
.ds-menu__list,
.ds-select-menu__list {
    position: absolute;
    z-index: var(--ds-z-popover);
    top: calc(100% + 8px);
    inset-inline-end: 0;
    background: var(--ds-surface-raised);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-menu);
    color: var(--ds-text-2);
    /* Closed layers take no space, so they can never push the page sideways */
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.ds-popover {
    min-width: 300px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px var(--ds-space-4);
}
.ds-popover.is-open,
.ds-menu.is-open > .ds-menu__list,
.ds-select-menu.is-open > .ds-select-menu__list,
.is-floating.is-open {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
}
@starting-style {
    .ds-popover.is-open,
    .ds-menu.is-open > .ds-menu__list,
    .ds-select-menu.is-open > .ds-select-menu__list { opacity: 0; transform: translateY(4px); }
}
.ds-popover--start,
.ds-menu--start > .ds-menu__list { inset-inline-end: auto; inset-inline-start: 0; }
.ds-popover__group + .ds-popover__group { margin-top: var(--ds-space-3); }
.ds-popover__group > .ds-overline { margin-bottom: var(--ds-space-2); }
.ds-popover__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--ds-space-2);
    margin: 14px calc(var(--ds-space-4) * -1) -14px;
    padding: 10px var(--ds-space-4);
    border-top: 1px solid var(--ds-divider);
}

.ds-menu { position: relative; display: inline-flex; z-index: 1; }
.ds-menu.is-open { z-index: 60; }
.ds-menu__list {
    top: calc(100% + 4px);
    min-width: 200px;
    padding: 6px;
    border-radius: var(--ds-radius-md);
    transform: translateY(4px);
}
.ds-menu--up > .ds-menu__list { top: auto; bottom: calc(100% + 4px); }
/* Open lists are pinned with position: fixed so scroll containers never clip them */
.ds-menu__list.is-floating,
.ds-select-menu__list.is-floating {
    position: fixed;
    inset: auto;
    z-index: var(--ds-z-float);
    transform: none;
}
.ds-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--ds-control-sm);
    margin: 0;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-2);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    text-align: start;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
}
.ds-menu__item > i { font-size: var(--ds-icon-sm); color: var(--ds-text-muted); flex-shrink: 0; }
.ds-menu__item:hover,
.ds-menu__item:focus-visible { background: var(--ds-surface-sunken); color: var(--ds-text); outline-offset: -2px; }
.ds-menu__item--danger,
.ds-menu__item--danger > i { color: var(--ds-danger-text); }
.ds-menu__item--danger:hover,
.ds-menu__item--danger:focus-visible { background: var(--ds-danger-bg); color: var(--ds-danger-text); }
.ds-menu__item:disabled { opacity: 0.5; cursor: not-allowed; }
.ds-menu__item[aria-current="true"] { color: var(--ds-brand-text); font-weight: var(--ds-fw-semibold); }
.ds-menu__sep { height: 1px; margin: 4px 6px; background: var(--ds-divider); }
.ds-menu__label {
    padding: 6px 12px 4px;
    font-size: var(--ds-fs-micro);
    font-weight: var(--ds-fw-bold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
    color: var(--ds-text-muted);
}

.ds-select-menu { position: relative; width: 100%; }
.ds-select-menu__trigger {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    width: 100%;
    text-align: start;
    cursor: pointer;
}
.ds-select-menu__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-select-menu__value.is-placeholder { color: var(--ds-text-subtle); font-weight: var(--ds-fw-regular); }
.ds-select-menu__list {
    top: calc(100% + 4px);
    inset-inline: 0;
    min-width: 100%;
    max-height: 280px;
    padding: 6px;
    overflow-y: auto;
    border-radius: var(--ds-radius-md);
    transform: translateY(4px);
}
.ds-select-menu__search {
    margin: -2px -2px 6px;
    padding: 2px 2px 6px;
    border-bottom: 1px solid var(--ds-divider);
}
.ds-select-menu__search .ds-input { height: 32px; min-height: 32px; font-size: var(--ds-fs-small); }
.ds-select-menu__empty { padding: 10px 12px; font-size: var(--ds-fs-small); color: var(--ds-text-muted); }
.ds-option {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    width: 100%;
    min-height: var(--ds-control-sm);
    margin: 0;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--ds-radius-xs);
    background: transparent;
    color: var(--ds-text-2);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    text-align: start;
    cursor: pointer;
}
.ds-option:hover,
.ds-option:focus-visible { background: var(--ds-surface-sunken); outline-offset: -2px; }
.ds-option[aria-selected="true"] { color: var(--ds-text); font-weight: var(--ds-fw-semibold); }
.ds-option[aria-selected="true"]::after {
    content: "";
    width: 7px;
    height: 12px;
    margin-inline-start: auto;
    /* A checkmark is not a directional icon: keep its geometry identical in RTL. */
    border-right: 2px solid var(--ds-brand-text);
    border-bottom: 2px solid var(--ds-brand-text);
    transform: rotate(45deg) translateY(-2px);
}
.ds-option:disabled { color: var(--ds-text-subtle); cursor: not-allowed; }
.ds-option[hidden] { display: none; }
.ds-option--create { color: var(--ds-brand-text); font-weight: var(--ds-fw-medium); overflow-wrap: anywhere; }
.ds-option--create .iconsax { margin-inline-end: var(--ds-space-1); font-size: var(--ds-icon-sm); vertical-align: -2px; }
/* Multiple: a checkbox square leads each option */
.ds-select-menu[data-ds-multiple] .ds-option::before {
    content: "";
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1.5px solid var(--ds-control-border);
    border-radius: 4px;
    background: var(--ds-surface) center / 10px no-repeat;
}
.ds-select-menu[data-ds-multiple] .ds-option[aria-selected="true"]::before {
    border-color: var(--ds-brand);
    background-color: var(--ds-brand);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l2.5 2.5L9 1' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.ds-select-menu[data-ds-multiple] .ds-option[aria-selected="true"]::after { display: none; }

/* ── 10. Table, selection, list cards, board ───────────────────────────── */
.ds-table-wrap {
    /* Positioned, so visually hidden labels in a wide table stay inside its scroll area instead of widening the page */
    position: relative;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ds-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    color: var(--ds-text-2);
}
.ds-table thead th {
    padding: 12px;
    border: 0;
    background: var(--ds-surface-table-head);
    color: var(--ds-text-3);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    text-align: start;
    white-space: nowrap;
    vertical-align: middle;
}
.ds-table thead th:first-child {
    padding-inline-start: var(--ds-space-4);
    border-start-start-radius: var(--ds-radius-sm);
    border-end-start-radius: var(--ds-radius-sm);
}
.ds-table thead th:last-child {
    padding-inline-end: var(--ds-space-4);
    border-start-end-radius: var(--ds-radius-sm);
    border-end-end-radius: var(--ds-radius-sm);
}
.ds-table tbody td {
    padding: 14px 12px;
    border: 0;
    border-bottom: 1px solid var(--ds-divider);
    background: transparent;
    vertical-align: middle;
    transition: background-color 0.15s ease;
}
.ds-table tbody td:first-child { padding-inline-start: var(--ds-space-4); }
.ds-table tbody td:last-child { padding-inline-end: var(--ds-space-4); }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr:hover td { background: var(--ds-surface-row-hover); }
.ds-table tbody tr.is-clickable { cursor: pointer; }
.ds-table tbody tr.is-selected td { background: var(--ds-brand-softer); }
.ds-table tbody tr.is-new td { animation: ds-row-in 1.2s ease; }
@keyframes ds-row-in { from { background-color: var(--ds-brand-tint); } }
.ds-table .ds-col-actions { width: 1%; text-align: end; white-space: nowrap; }
.ds-table .ds-col-check { width: 40px; padding-inline-end: 0; }
.ds-table .ds-col-num { text-align: end; font-variant-numeric: tabular-nums; }
.ds-table--compact tbody td { padding-block: 10px; }
/* Buttons and chips side by side in a cell */
.ds-row-actions { display: inline-flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.ds-row-actions--start { justify-content: flex-start; }
/* A section heading between groups of rows */
.ds-table tbody tr.ds-table__group th {
    padding: 10px var(--ds-space-4);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    text-align: start;
    color: var(--ds-text);
    background: var(--ds-surface-muted);
    border-bottom: 1px solid var(--ds-divider);
}
.ds-table tbody tr.ds-table__group th > * + * { margin-inline-start: var(--ds-space-2); }
/* Below 768px each row becomes a card: <td data-label="Status">. Keeps one table for every width. */
@media (max-width: 767.98px) {
    .ds-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .ds-table--stack, .ds-table--stack tbody, .ds-table--stack tr, .ds-table--stack td { display: block; width: 100%; }
    .ds-table--stack tbody tr {
        padding: var(--ds-space-3) var(--ds-space-4);
        border-bottom: 1px solid var(--ds-divider);
    }
    .ds-table--stack tbody tr:last-child { border-bottom: 0; }
    .ds-table--stack tbody tr.ds-table__group { padding: 0; }
    .ds-table--stack tbody tr.ds-table__group th { display: block; }
    .ds-table--stack tbody td,
    .ds-table--stack tbody td:first-child,
    .ds-table--stack tbody td:last-child {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--ds-space-3);
        padding: 6px 0;
        border-bottom: 0;
        text-align: start;
    }
    .ds-table--stack tbody td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 45%;
        font-size: var(--ds-fs-small);
        font-weight: var(--ds-fw-medium);
        color: var(--ds-text-muted);
    }
    .ds-table--stack tbody td.ds-col-actions { justify-content: flex-end; width: 100%; }
    .ds-table--stack tbody tr:hover td { background: transparent; }
    .ds-table--stack .ds-col-num { text-align: start; }
}
/* Sortable header: <th aria-sort><button class="ds-th-sort"> */
.ds-th-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.ds-th-sort::after {
    content: "";
    width: 0;
    height: 0;
    border-inline: 4px solid transparent;
    border-top: 5px solid var(--ds-text-subtle);
    opacity: 0.6;
}
th[aria-sort="ascending"] .ds-th-sort::after { border-top: 0; border-bottom: 5px solid var(--ds-brand-text); opacity: 1; }
th[aria-sort="descending"] .ds-th-sort::after { border-top-color: var(--ds-brand-text); opacity: 1; }

.ds-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-cell__primary {
    overflow: hidden;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-cell__meta {
    overflow: hidden;
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-amount {
    font-size: var(--ds-fs-body-lg);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Bulk selection bar: appears when rows are selected inside [data-ds-selection] */
.ds-bulkbar {
    position: sticky;
    bottom: var(--ds-space-4);
    z-index: 10;
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-2) var(--ds-space-3);
    margin-top: var(--ds-space-3);
    padding-block: 8px; padding-inline: var(--ds-space-4) 8px;
    background: var(--ds-surface-raised);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-menu);
}
.ds-bulkbar.is-active { display: flex; }
.ds-bulkbar__count { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-bold); color: var(--ds-text); }
.ds-bulkbar__actions { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); margin-inline-start: auto; }

.ds-list-cards { display: flex; flex-direction: column; gap: 10px; }
.ds-list-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    padding: 14px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    color: var(--ds-text-2);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ds-list-card:hover {
    border-color: var(--ds-brand-line);
    box-shadow: var(--ds-shadow-hover);
}
.ds-list-card:has(.ds-menu.is-open) { z-index: 40; }
.ds-list-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

/* Board: status columns of cards (Tasks Kanban) */
.ds-board {
    display: grid;
    grid-auto-columns: minmax(260px, 1fr);
    grid-auto-flow: column;
    gap: 14px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
}
.ds-board__col { scroll-snap-align: start; }
.ds-board__col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: calc(100vh - 280px);
    background: var(--ds-surface-subtle);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
}
.ds-board__head {
    --ds-status-color: var(--ds-text-subtle);
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: 12px 14px;
    border-bottom: 1px solid var(--ds-divider);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
}
.ds-board__head .ds-segmented__count { margin-inline-start: auto; }
.ds-board__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
    padding: 10px;
    overflow-y: auto;
}
.ds-board__drop {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    border: 1.5px dashed var(--ds-border-strong);
    border-radius: var(--ds-radius-md);
    font-size: var(--ds-fs-small);
    color: var(--ds-text-muted);
}
.ds-board__drop.is-over { border-color: var(--ds-brand); background: var(--ds-brand-softer); color: var(--ds-brand-text); }

/* ── 11. Badge, status, tag, due, avatar, person ───────────────────────── */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 2px 10px;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-t-bg);
    color: var(--ds-t-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.2;
    white-space: nowrap;
}
.ds-badge > i { font-size: var(--ds-icon-xs); color: inherit; }
.ds-badge--caps {
    min-height: 20px;
    padding: 2px 8px;
    border-radius: var(--ds-radius-xs);
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-bold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
}

/* Record status: readable label + a dot (or icon) in the status color */
.ds-status {
    --ds-status-color: var(--ds-text-subtle);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ds-text-2);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    white-space: nowrap;
}
.ds-status > i { color: var(--ds-status-color); font-size: var(--ds-icon-sm); }
.ds-status__dot,
.ds-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ds-status-color, currentColor);
}
[data-status="pending"] { --ds-status-color: var(--ds-status-pending); }
[data-status="processing"] { --ds-status-color: var(--ds-status-processing); }
[data-status="confirmed"] { --ds-status-color: var(--ds-status-confirmed); }
[data-status="shipped"] { --ds-status-color: var(--ds-status-shipped); }
[data-status="paid"] { --ds-status-color: var(--ds-status-paid); }
[data-status="delivered"] { --ds-status-color: var(--ds-status-delivered); }
[data-status="cancelled"] { --ds-status-color: var(--ds-status-cancelled); }
[data-status="refunded"] { --ds-status-color: var(--ds-status-refunded); }
[data-status="returned"] { --ds-status-color: var(--ds-status-returned); }
[data-status="deleted"] { --ds-status-color: var(--ds-status-deleted); }
[data-status="in-progress"] { --ds-status-color: var(--ds-status-in-progress); }
[data-status="solved"] { --ds-status-color: var(--ds-status-solved); }
.ds-status--success { --ds-status-color: var(--ds-success); }
.ds-status--warning { --ds-status-color: var(--ds-warning); }
.ds-status--danger { --ds-status-color: var(--ds-danger); }
.ds-status--info { --ds-status-color: var(--ds-info); }
.ds-status--brand { --ds-status-color: var(--ds-brand-text); }

.ds-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 160px;
    min-height: 20px;
    padding: 2px 10px;
    overflow: hidden;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-brand-soft);
    color: var(--ds-brand-strong);
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-tag--neutral { background: var(--ds-neutral-bg); color: var(--ds-neutral-text); }
.ds-tag-list { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }

.ds-due {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--ds-radius-xs);
    background: var(--ds-neutral-bg);
    color: var(--ds-neutral-text);
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-semibold);
    white-space: nowrap;
}
.ds-due.is-soon { background: var(--ds-warning-bg); color: var(--ds-warning-text); }
.ds-due.is-overdue { background: var(--ds-danger-bg-strong); color: var(--ds-danger-text); }

.ds-avatar {
    --ds-avatar-size: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ds-avatar-size);
    height: var(--ds-avatar-size);
    min-width: var(--ds-avatar-size);
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 50%;
    background: var(--ds-surface-sunken);
    color: var(--ds-text-3);
    font-size: calc(var(--ds-avatar-size) * 0.38);
    font-weight: var(--ds-fw-bold);
    text-transform: uppercase;
}
.ds-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ds-avatar--sm { --ds-avatar-size: 28px; }
.ds-avatar--lg { --ds-avatar-size: 40px; }
.ds-avatar--brand { background: var(--ds-brand-tint); color: var(--ds-brand-text); }
.ds-avatar--square { border-radius: var(--ds-radius-sm); }
.ds-avatar-group { display: inline-flex; align-items: center; }
.ds-avatar-group > .ds-avatar { box-shadow: 0 0 0 2px var(--ds-surface); }
.ds-avatar-group > .ds-avatar + .ds-avatar { margin-inline-start: -8px; }
.ds-avatar-group__more { background: var(--ds-neutral-bg); color: var(--ds-neutral-text); font-size: var(--ds-fs-caption); text-transform: none; }

.ds-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ds-person__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ds-person__name {
    overflow: hidden;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.ds-person__name:hover { color: var(--ds-brand-text); }
.ds-person__meta {
    overflow: hidden;
    font-size: var(--ds-fs-small);
    color: var(--ds-text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── 12. Feedback: empty state, alert, banner, toast, tooltip ──────────── */
.ds-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-12) var(--ds-space-6);
    text-align: center;
    font-family: var(--ds-font);
}
.ds-empty .ds-icon-tile {
    --ds-tile-size: 64px;
    margin-bottom: var(--ds-space-4);
    border-radius: var(--ds-radius-xl);
    font-size: var(--ds-icon-xl);
}
.ds-empty__title {
    margin: 0 0 6px;
    font-size: var(--ds-fs-heading);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
}
.ds-empty__text {
    max-width: 340px;
    margin: 0 0 var(--ds-space-5);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: 1.5;
    color: var(--ds-text-muted);
}
.ds-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--ds-space-2); }
.ds-empty--compact { padding: 28px var(--ds-space-4); }
.ds-empty--compact .ds-icon-tile { --ds-tile-size: 48px; margin-bottom: var(--ds-space-3); font-size: var(--ds-icon-lg); }

.ds-alert,
.ds-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--ds-t-line);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-t-bg);
    color: var(--ds-t-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: 1.45;
}
.ds-alert > i,
.ds-banner > i { flex-shrink: 0; font-size: var(--ds-icon-md); line-height: 1.1; color: inherit; }
.ds-alert__body,
.ds-banner__body { flex: 1; min-width: 0; }
.ds-alert__title,
.ds-banner__title { display: block; font-weight: var(--ds-fw-bold); }
.ds-alert[hidden],
.ds-banner[hidden] { display: none; }
/* Banner: page-level, full width, with an action and an optional dismiss */
.ds-banner { align-items: center; padding-block: 10px; padding-inline: var(--ds-space-4) 10px; border-radius: var(--ds-radius-md); }
.ds-banner__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2); }
.ds-banner .ds-icon-btn { color: inherit; }

/* Toast: short confirmation of a finished action (BbDs.toast) */
.ds-toast-region {
    position: fixed;
    inset: auto max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) auto;
    z-index: var(--ds-z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--ds-space-2);
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
html[dir="rtl"] .ds-toast-region { inset: auto auto max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); align-items: flex-start; }
.ds-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding-block: 12px; padding-inline: 14px 8px;
    background: var(--ds-surface-raised);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    box-shadow: var(--ds-shadow-menu);
    color: var(--ds-text-2);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: 1.45;
    pointer-events: auto;
    animation: ds-toast-in var(--ds-dur) var(--ds-ease);
}
/* The tone edge tells success, error, warning and info apart at a glance (with the icon: never colour alone) */
.ds-toast { border-inline-start: 3px solid var(--ds-t); padding-inline-start: 12px; }
.ds-toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--ds-dur) ease, transform var(--ds-dur) ease; }
@keyframes ds-toast-in { from { opacity: 0; transform: translateY(8px); } }
.ds-toast > i { flex-shrink: 0; margin-top: 1px; font-size: var(--ds-icon-md); color: var(--ds-t); }
.ds-toast__body { flex: 1; min-width: 0; }
.ds-toast__title { display: block; font-weight: var(--ds-fw-bold); color: var(--ds-text); }
.ds-toast__action {
    margin: 0;
    padding: 2px 6px;
    border: 0;
    border-radius: var(--ds-radius-xs);
    background: none;
    color: var(--ds-brand-text);
    font: inherit;
    font-weight: var(--ds-fw-bold);
    cursor: pointer;
}
.ds-toast__action:hover { background: var(--ds-brand-soft); }
.ds-toast .ds-icon-btn { width: calc(var(--ds-control-sm) - 4px); height: calc(var(--ds-control-sm) - 4px); min-width: 0; margin-top: -4px; }

/* Tooltip: [data-ds-tooltip="Text"] on any element; JS draws one floating label */
.ds-tooltip {
    position: fixed;
    z-index: var(--ds-z-toast);
    max-width: 260px;
    padding: 6px 9px;
    border-radius: var(--ds-radius-xs);
    background: var(--ds-tooltip-bg);
    color: var(--ds-tooltip-text);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-medium);
    line-height: 1.35;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ds-dur-fast) ease, visibility var(--ds-dur-fast);
}
.ds-tooltip.is-visible { opacity: 1; visibility: visible; }

/* ── 13. Progress, spinner, skeleton, loading ──────────────────────────── */
.ds-progress { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ds-progress__head {
    display: flex;
    justify-content: space-between;
    gap: var(--ds-space-2);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-3);
}
.ds-progress__value { color: var(--ds-text); font-variant-numeric: tabular-nums; }
.ds-progress__track {
    height: 8px;
    overflow: hidden;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-surface-sunken);
}
.ds-progress--sm .ds-progress__track { height: 4px; }
.ds-progress__bar {
    width: var(--ds-value, 0%);
    max-width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--ds-t-graphic, var(--ds-t));
    transition: width var(--ds-dur-slow) var(--ds-ease);
}
.ds-progress--success { --ds-t-graphic: var(--ds-success-graphic); }
.ds-progress--warning { --ds-t-graphic: var(--ds-warning-graphic); }

.ds-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid var(--ds-brand-tint);
    border-top-color: var(--ds-brand-text);
    border-radius: 50%;
    animation: ds-spin 0.7s linear infinite;
}
.ds-spinner--sm { width: 14px; height: 14px; }
.ds-spinner--lg { width: 32px; height: 32px; border-width: 3px; }

.ds-skeleton {
    display: block;
    height: 12px;
    border-radius: var(--ds-radius-xs);
    background: linear-gradient(90deg, var(--ds-skeleton) 25%, var(--ds-skeleton-shine) 37%, var(--ds-skeleton) 63%) 0 0 / 400% 100%;
    animation: ds-shimmer 1.4s ease infinite;
}
.ds-skeleton--title { height: 18px; width: 40%; }
.ds-skeleton--circle { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.ds-skeleton--block { height: 96px; border-radius: var(--ds-radius-lg); }
.ds-skeleton-stack { display: flex; flex-direction: column; gap: 10px; }
.ds-skeleton-stack > .ds-skeleton:last-child:not(:first-child) { width: 70%; }
@keyframes ds-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Busy region: aria-busy="true" dims the content and shows a spinner */
.ds-loading { position: relative; }
.ds-loading[aria-busy="true"] > * { opacity: 0.45; pointer-events: none; transition: opacity var(--ds-dur) ease; }
.ds-loading[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: min(50%, 120px);
    inset-inline-start: 50%;
    width: 28px;
    height: 28px;
    margin-block: -14px 0; margin-inline: -14px 0;
    border: 3px solid var(--ds-brand-tint);
    border-top-color: var(--ds-brand-text);
    border-radius: 50%;
    animation: ds-spin 0.7s linear infinite;
}

/* ── 14. Pager, stepper, timeline ──────────────────────────────────────── */
.ds-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--ds-space-3);
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-subtle);
    font-family: var(--ds-font);
}
.ds-pager__info {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-3) var(--ds-space-4);
    min-width: 0;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-3);
}
.ds-pager__size { display: inline-flex; align-items: center; gap: var(--ds-space-2); white-space: nowrap; }
.ds-pager__controls { display: inline-flex; align-items: center; gap: 4px; }
.ds-pager__page,
.ds-pager__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--ds-control-sm);
    height: var(--ds-control-sm);
    margin: 0;
    padding: 0 10px;
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-bold);
    line-height: 1;
    text-decoration: none !important;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}
.ds-pager__btn { padding: 0; font-size: var(--ds-icon-sm); }
.ds-pager__page:hover,
.ds-pager__btn:hover { border-color: var(--ds-brand); color: var(--ds-brand-text); }
.ds-pager__page[aria-current="page"],
.ds-pager__page.is-active {
    border-color: var(--ds-brand);
    background: var(--ds-brand);
    color: var(--ds-text-on-brand);
}
.ds-pager__btn:disabled,
.ds-pager__btn.is-disabled {
    opacity: 0.45;
    background: var(--ds-surface-sunken);
    color: var(--ds-text-subtle);
    pointer-events: none;
}
.ds-pager__ellipsis { min-width: 16px; text-align: center; color: var(--ds-text-muted); font-weight: var(--ds-fw-semibold); }
html[dir="rtl"] .ds-pager__btn > i { transform: scaleX(-1); }
@media (max-width: 575.98px) {
    .ds-pager { flex-direction: column; align-items: stretch; }
    .ds-pager__info { justify-content: center; }
    .ds-pager__size { display: none; }
    .ds-pager__controls { justify-content: space-between; }
    .ds-pager__page:not([aria-current="page"]),
    .ds-pager__ellipsis { display: none; }
}

/* Stepper: multi-step flows (campaign compose, onboarding, import) */
.ds-stepper {
    display: flex;
    gap: var(--ds-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: ds-step;
}
.ds-stepper__step {
    position: relative;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 10px;
    min-width: 0;
    counter-increment: ds-step;
}
.ds-stepper__step:not(:last-child)::after {
    content: "";
    flex: 1 1 auto;
    min-width: 12px;
    height: 2px;
    border-radius: 1px;
    background: var(--ds-border);
}
.ds-stepper__step.is-done:not(:last-child)::after { background: var(--ds-brand); }
.ds-stepper__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 2px solid var(--ds-border-strong);
    border-radius: 50%;
    background: var(--ds-surface);
    color: var(--ds-text-3);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-bold);
}
.ds-stepper__marker:empty::before { content: counter(ds-step); }
.ds-stepper__step.is-current .ds-stepper__marker { border-color: var(--ds-brand); color: var(--ds-brand-text); box-shadow: var(--ds-ring); }
.ds-stepper__step.is-done .ds-stepper__marker { border-color: var(--ds-brand); background: var(--ds-brand); color: var(--ds-text-on-brand); }
.ds-stepper__step.is-done .ds-stepper__marker:empty::before {
    content: "";
    width: 10px;
    height: 6px;
    border-inline-start: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg) translate(calc(1px * var(--ds-dir, 1)), -1px);
}
.ds-stepper__text { display: flex; flex-direction: column; min-width: 0; }
.ds-stepper__label {
    overflow: hidden;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-3);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-stepper__step.is-current .ds-stepper__label,
.ds-stepper__step.is-done .ds-stepper__label { color: var(--ds-text); }
.ds-stepper__desc { font-size: var(--ds-fs-caption); color: var(--ds-text-muted); white-space: nowrap; }
@media (max-width: 575.98px) {
    .ds-stepper__step:not(.is-current) .ds-stepper__text { display: none; }
}

/* Timeline: activity, comments, logs */
.ds-timeline { margin: 0; padding: 0; list-style: none; }
.ds-timeline__item {
    position: relative;
    display: flex;
    gap: var(--ds-space-3);
    padding-bottom: var(--ds-space-4);
}
.ds-timeline__item:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 30px;
    bottom: 4px;
    inset-inline-start: 13px;
    width: 2px;
    border-radius: 1px;
    background: var(--ds-divider);
}
.ds-timeline__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ds-neutral-bg);
    color: var(--ds-text-muted);
    font-size: var(--ds-icon-xs);
}
.ds-timeline__marker.ds-icon-tile { --ds-tile-size: 28px; border-radius: 50%; font-size: var(--ds-icon-xs); }
.ds-timeline__content { flex: 1; min-width: 0; padding-top: 4px; }
.ds-timeline__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.ds-timeline__title { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-timeline__time { font-size: var(--ds-fs-caption); color: var(--ds-text-muted); }
.ds-timeline__body {
    margin: 6px 0 0;
    font-size: var(--ds-fs-body);
    line-height: 1.5;
    color: var(--ds-text-2);
    white-space: pre-wrap;
    word-break: break-word;
}
.ds-timeline__body--bubble {
    padding: 10px 12px;
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-subtle);
    border: 1px solid var(--ds-divider);
}

/* ── 15. Forms ─────────────────────────────────────────────────────────── */
.ds-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.ds-form-grid {
    display: grid;
    /* At most two columns, one when the container is under ~500px (works inside narrow panels and modals too) */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(240px, calc((100% - var(--ds-space-4)) / 2))), 1fr));
    gap: 14px var(--ds-space-4);
    max-width: 960px;
}
.ds-form-grid > .ds-span-full,
.ds-form-grid > .ds-form-section { grid-column: 1 / -1; }
.ds-form-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ds-divider);
}
.ds-form-section:last-child { padding-bottom: 0; border-bottom: 0; }
.ds-form-section__title { margin: 0; font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-form-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    padding-top: var(--ds-space-2);
}

.ds-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.ds-field__label {
    display: block;
    margin: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    line-height: 1.3;
    color: var(--ds-text-3);
}
.ds-field__required { color: var(--ds-danger-text); }
.ds-field__optional { font-weight: var(--ds-fw-regular); color: var(--ds-text-muted); }
.ds-field__hint,
.ds-field__error {
    margin: 0;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-medium);
    line-height: 1.4;
    color: var(--ds-text-muted);
}
.ds-field__error { color: var(--ds-danger-text); }
.ds-field__error:empty { display: none; }
.ds-field__row { display: flex; align-items: center; gap: var(--ds-space-2); }
.ds-field__row > .ds-input,
.ds-field__row > .ds-select,
.ds-field__row > .ds-select-menu { flex: 1; min-width: 0; }
.ds-field__counter { align-self: flex-end; font-size: var(--ds-fs-caption); color: var(--ds-text-muted); font-variant-numeric: tabular-nums; }

.ds-input,
.ds-select,
.ds-textarea,
.ds-select-menu__trigger {
    display: block;
    width: 100%;
    height: var(--ds-control-md);
    min-height: var(--ds-control-md);
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-sm);
    background-color: var(--ds-surface);
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: calc(var(--ds-control-md) - 2px);
    box-shadow: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.ds-input::placeholder,
.ds-textarea::placeholder { color: var(--ds-text-muted); font-weight: var(--ds-fw-regular); opacity: 1; }
.ds-input:hover,
.ds-select:hover,
.ds-textarea:hover,
.ds-select-menu__trigger:hover { border-color: var(--ds-text-3); }
.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus,
.ds-select-menu__trigger:focus-visible,
.ds-select-menu.is-open > .ds-select-menu__trigger {
    border-color: var(--ds-brand-text);
    box-shadow: var(--ds-ring);
}
.ds-input:disabled,
.ds-select:disabled,
.ds-textarea:disabled,
.ds-select-menu__trigger:disabled,
.ds-input[readonly]:not(.ds-input--picker) {
    background-color: var(--ds-surface-muted);
    color: var(--ds-text-muted);
    cursor: not-allowed;
}
.ds-input.is-invalid,
.ds-select.is-invalid,
.ds-textarea.is-invalid,
.ds-select-menu__trigger.is-invalid,
.ds-input[aria-invalid="true"],
.ds-select[aria-invalid="true"],
.ds-textarea[aria-invalid="true"] {
    border-color: var(--ds-danger);
    box-shadow: var(--ds-ring-danger);
}
.ds-input:-webkit-autofill {
    -webkit-text-fill-color: var(--ds-text);
    box-shadow: 0 0 0 1000px var(--ds-surface) inset;
}
.ds-textarea {
    height: auto;
    min-height: 88px;
    padding: 10px 12px;
    line-height: 1.45;
    resize: vertical;
}
.ds-select,
.ds-select-menu__trigger {
    padding-inline-end: 36px;
    background-image: var(--ds-chevron);
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px 7px;
    cursor: pointer;
}
html[dir="rtl"] .ds-select,
html[dir="rtl"] .ds-select-menu__trigger { background-position: left 14px center; }

.ds-input-icon { position: relative; display: block; width: 100%; }
.ds-input-icon > i {
    position: absolute;
    top: 50%;
    inset-inline-start: 12px;
    transform: translateY(-50%);
    font-size: var(--ds-icon-sm);
    color: var(--ds-text-muted);
    pointer-events: none;
}
.ds-input-icon > .ds-input { padding-inline-start: 38px; }
.ds-input-icon--end > i { inset-inline-start: auto; inset-inline-end: 12px; }
.ds-input-icon--end > .ds-input { padding-inline: 12px 38px; }

/* Input group: prefix / suffix addons (currency, +216, https://), a copy button */
.ds-input-group { display: flex; width: 100%; min-width: 0; }
.ds-input-group > * { border-radius: 0; }
.ds-input-group > * + * { margin-inline-start: -1px; }
.ds-input-group > :first-child { border-start-start-radius: var(--ds-radius-sm); border-end-start-radius: var(--ds-radius-sm); }
.ds-input-group > :last-child { border-start-end-radius: var(--ds-radius-sm); border-end-end-radius: var(--ds-radius-sm); }
.ds-input-group > .ds-input,
.ds-input-group > .ds-select { flex: 1 1 auto; min-width: 0; }
.ds-input-group > .ds-select:first-child:not(:only-child) { flex: 0 0 auto; width: auto; }
.ds-input-group > :focus { position: relative; z-index: 1; }
.ds-input-group__addon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 12px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface-subtle);
    color: var(--ds-text-3);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    white-space: nowrap;
}
.ds-input-group > .ds-btn { height: auto; border-color: var(--ds-control-border); box-shadow: none; }
.ds-copy .ds-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--ds-fs-small); }

/* Color: swatch + hex, kept in sync by JS */
.ds-color { display: flex; gap: var(--ds-space-2); width: 100%; }
.ds-color__swatch {
    width: var(--ds-control-md);
    height: var(--ds-control-md);
    flex-shrink: 0;
    padding: 3px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    cursor: pointer;
}
.ds-color__swatch::-webkit-color-swatch-wrapper { padding: 0; }
.ds-color__swatch::-webkit-color-swatch { border: 0; border-radius: 5px; }
.ds-color__swatch::-moz-color-swatch { border: 0; border-radius: 5px; }
.ds-color .ds-input { flex: 1; text-transform: uppercase; font-variant-numeric: tabular-nums; }

/* Dropzone: label wrapping a visually hidden file input */
.ds-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--ds-space-6) var(--ds-space-4);
    border: 1.5px dashed var(--ds-border-strong);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-subtle);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--ds-dur-fast) ease, background-color var(--ds-dur-fast) ease;
}
.ds-dropzone:hover,
.ds-dropzone.is-dragover { border-color: var(--ds-brand); background: var(--ds-brand-softer); }
.ds-dropzone > input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ds-dropzone .ds-icon-tile { --ds-tile-size: 44px; margin-bottom: 4px; font-size: var(--ds-icon-lg); }
.ds-dropzone__title { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-dropzone__title u { color: var(--ds-brand-text); text-decoration: none; }
.ds-dropzone__hint { font-size: var(--ds-fs-small); color: var(--ds-text-muted); }
.ds-dropzone__files { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.ds-dropzone__files:empty { display: none; }

.ds-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--ds-control-md);
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text-2);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    cursor: pointer;
}
.ds-check--plain { min-height: 0; padding: 0; border: 0; background: transparent; }
.ds-check input,
.ds-choice input,
.ds-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--ds-brand);
    cursor: pointer;
}
.ds-check:not(.ds-check--plain):has(input:checked) { border-color: var(--ds-brand-line); background: var(--ds-brand-softer); }
.ds-check:has(input:focus-visible),
.ds-choice:has(input:focus-visible) { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }

/* Every checkbox in the product is this one, the Audience table's. !important because page stylesheets size Metronic's by id. */
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]),
.ds-check input[type="checkbox"],
.ds-choice input[type="checkbox"] {
    position: relative;
    flex: none;
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    padding: 0 !important;
    border: 1.5px solid var(--ds-border) !important;
    border-radius: 3px !important;
    background: var(--ds-surface) center / 10px 10px no-repeat !important;
    box-shadow: none !important;
    vertical-align: middle;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
/* Small to look at, comfortable to hit */
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"])::after,
.ds-check input[type="checkbox"]::after,
.ds-choice input[type="checkbox"]::after {
    content: "";
    position: absolute;
    inset: -6px;
}
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):hover:not(:checked, :disabled),
.ds-check input[type="checkbox"]:hover:not(:checked, :disabled),
.ds-choice input[type="checkbox"]:hover:not(:checked, :disabled) { border-color: var(--ds-control-border) !important; }
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):checked,
.ds-check input[type="checkbox"]:checked,
.ds-choice input[type="checkbox"]:checked {
    border-color: var(--ds-brand) !important;
    background-color: var(--ds-brand) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 11' width='13' height='11' fill='none'%3e%3cpath d='M11.0426 1.02893C11.3258 0.695792 11.8254 0.655283 12.1585 0.938451C12.4917 1.22162 12.5322 1.72124 12.249 2.05437L5.51985 9.97104C5.23224 10.3094 4.72261 10.3451 4.3907 10.05L0.828197 6.88335C0.50141 6.59288 0.471975 6.09249 0.762452 5.7657C1.05293 5.43891 1.55332 5.40948 1.88011 5.69995L4.83765 8.32889L11.0426 1.02893Z' fill='%23ffffff'/%3e%3c/svg%3e") !important;
}
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):indeterminate,
.ds-check input[type="checkbox"]:indeterminate,
.ds-choice input[type="checkbox"]:indeterminate {
    border-color: var(--ds-brand) !important;
    background-color: var(--ds-brand) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e") !important;
}
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):focus,
.ds-check input[type="checkbox"]:focus,
.ds-choice input[type="checkbox"]:focus { border-color: var(--ds-brand) !important; box-shadow: var(--ds-ring) !important; }
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):focus-visible,
.ds-check input[type="checkbox"]:focus-visible,
.ds-choice input[type="checkbox"]:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }
input[type="checkbox"]:is(.form-check-input, .ds-checkbox, .adm-check-input):not(.form-switch *, [role="switch"]):disabled,
.ds-check input[type="checkbox"]:disabled,
.ds-choice input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* Theme toggle for pages without the account menu. Shows where a click leads: a moon in light, a sun in dark. */
.ds-theme-toggle {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--ds-border);
    border-radius: 6px;
    background: var(--ds-surface);
    color: var(--ds-text-3);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.ds-theme-toggle:hover { border-color: var(--ds-border-strong); background: var(--ds-surface-muted); color: var(--ds-text); }
.ds-theme-toggle:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }
.ds-theme-toggle svg { width: 18px; height: 18px; }
.ds-theme-toggle__sun { display: none; }
[data-bs-theme="dark"] .ds-theme-toggle__sun { display: block; }
[data-bs-theme="dark"] .ds-theme-toggle__moon { display: none; }
.ds-theme-toggle--floating { position: fixed; top: 16px; inset-inline-end: 16px; z-index: var(--ds-z-sticky, 100); }
/* A logo drawn for one background */
[data-bs-theme="dark"] .ds-only-light { display: none !important; }
:root:not([data-bs-theme="dark"]) .ds-only-dark { display: none !important; }
.ds-choice-list { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-choice-list--row { flex-direction: row; flex-wrap: wrap; }
.ds-choice-list--row > .ds-choice { flex: 1 1 200px; }
.ds-choice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    cursor: pointer;
    transition: border-color var(--ds-dur-fast) ease, background-color var(--ds-dur-fast) ease;
}
.ds-choice input { margin-top: 2px; }
.ds-choice:hover { border-color: var(--ds-border-strong); }
.ds-choice:has(input:checked) { border-color: var(--ds-brand-line); background: var(--ds-brand-softer); }
.ds-choice__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-choice__title { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-choice__desc { margin: 0; font-size: var(--ds-fs-small); font-weight: var(--ds-fw-medium); color: var(--ds-text-muted); }

.ds-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 10px;
    margin: 0;
    cursor: pointer;
}
.ds-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ds-switch__track {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-switch-off);
    transition: background-color 0.15s ease;
}
.ds-switch__track::before {
    content: "";
    position: absolute;
    top: 2px;
    inset-inline-start: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--ds-switch-thumb);
    box-shadow: var(--ds-switch-thumb-shadow);
    transition: transform 0.15s ease;
}
.ds-switch input:checked + .ds-switch__track { background: var(--ds-brand); }
.ds-switch input:checked + .ds-switch__track::before { transform: translateX(calc(16px * var(--ds-dir, 1))); }
html[dir="rtl"] .ds-switch input:checked + .ds-switch__track::before { transform: translateX(-16px); }
.ds-switch input:focus-visible + .ds-switch__track { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }
.ds-switch input:disabled + .ds-switch__track { opacity: 0.5; cursor: not-allowed; }
.ds-switch__label { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-medium); color: var(--ds-text-2); }

.ds-setting-list { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-4);
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
}
.ds-setting__text { min-width: 0; }
.ds-setting__title { font-size: var(--ds-fs-body-lg); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-setting__desc { margin: 2px 0 0; font-size: var(--ds-fs-small); font-weight: var(--ds-fw-medium); line-height: 1.4; color: var(--ds-text-muted); }

.ds-dl { display: flex; flex-direction: column; margin: 0; }
.ds-dl__row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ds-divider);
}
.ds-dl__row:last-child { border-bottom: 0; }
.ds-dl dt { margin: 0; font-size: var(--ds-fs-small); font-weight: var(--ds-fw-medium); color: var(--ds-text-muted); }
.ds-dl dd { margin: 0; font-size: var(--ds-fs-body-lg); font-weight: var(--ds-fw-medium); color: var(--ds-text); word-break: break-word; }
.ds-dl--inline .ds-dl__row { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--ds-space-3); }
.ds-dl--boxed {
    padding: 4px 14px;
    border: 1px solid var(--ds-divider);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-subtle);
}

/* Disclosure: native <details> for collapsible sections and FAQs */
.ds-disclosure-group { display: flex; flex-direction: column; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); background: var(--ds-surface); }
.ds-disclosure-group > .ds-disclosure + .ds-disclosure { border-top: 1px solid var(--ds-divider); }
.ds-disclosure > summary {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: 12px 14px;
    color: var(--ds-text);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    list-style: none;
    cursor: pointer;
    border-radius: var(--ds-radius-md);
}
.ds-disclosure > summary::-webkit-details-marker { display: none; }
.ds-disclosure > summary::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-inline-start: auto;
    border-inline-end: 2px solid var(--ds-text-muted);
    border-bottom: 2px solid var(--ds-text-muted);
    transform: rotate(45deg) translateY(-2px);
    transition: transform var(--ds-dur) ease;
}
.ds-disclosure[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.ds-disclosure__body { padding: 0 14px 14px; font-size: var(--ds-fs-body); line-height: 1.5; color: var(--ds-text-2); }

/* Hit area: a 32px target around a 16px checkbox (table selection) */
.ds-hit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--ds-control-sm);
    min-height: var(--ds-control-sm);
    margin: -8px;
    cursor: pointer;
}

/* Field groups (radios, choices, pills) are a fieldset with a legend so the group has a name */
fieldset.ds-field { min-width: 0; padding: 0; border: 0; }
legend.ds-field__label { float: none; width: auto; padding: 0; margin: 0 0 6px; font-size: var(--ds-fs-small); line-height: 1.3; }

/* Setting row as one big label: the whole row toggles its switch */
.ds-setting__text,
.ds-setting__title,
.ds-setting__desc { display: block; }
label.ds-setting { cursor: pointer; }
label.ds-setting:hover { border-color: var(--ds-border-strong); }
label.ds-setting:has(input:focus-visible) { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }
label.ds-setting:has(input:focus-visible) .ds-switch__track { outline: 0; }

/* Recommended option stands out (Von Restorff) */
.ds-choice__title { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ds-choice--recommended { border-color: var(--ds-brand-line); }

/* Stepper count: "Step 3 of 4" replaces hidden labels on phones */
.ds-stepper__count { display: none; margin: 8px 0 0; font-size: var(--ds-fs-small); font-weight: var(--ds-fw-semibold); color: var(--ds-text-3); }
@media (max-width: 575.98px) { .ds-stepper__count { display: block; } }

/* Checklist: what is left to set up (Zeigarnik, goal-gradient) */
.ds-checklist { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.ds-checklist__items { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); background: var(--ds-surface); }
.ds-checklist__item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border-top: 1px solid var(--ds-divider); font-size: var(--ds-fs-body); color: var(--ds-text); }
.ds-checklist__item:first-child { border-top: 0; }
.ds-checklist__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: 2px solid var(--ds-control-border);
    border-radius: 50%;
}
.ds-checklist__item.is-done .ds-checklist__mark { border-color: var(--ds-success-graphic); background: var(--ds-success-graphic); }
.ds-checklist__item.is-done .ds-checklist__mark::after {
    content: "";
    width: 9px;
    height: 5px;
    border-inline-start: 2px solid var(--ds-text-on-brand);
    border-bottom: 2px solid var(--ds-text-on-brand);
    transform: rotate(-45deg) translate(calc(1px * var(--ds-dir, 1)), -1px);
}
.ds-checklist__item.is-done .ds-checklist__label { color: var(--ds-text-muted); text-decoration: line-through; }
.ds-checklist__label { flex: 1; min-width: 0; }
.ds-checklist__item .ds-btn { margin-inline-start: auto; }

/* ── 16. Overlays ──────────────────────────────────────────────────────── */
.ds-overlay-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-shrink: 0;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5);
    border-bottom: 1px solid var(--ds-border);
    background: var(--ds-surface-subtle);
}
.ds-overlay-header__text { flex: 1; min-width: 0; }
.ds-overlay-title {
    margin: 0;
    padding: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-title);
    font-weight: var(--ds-fw-bold);
    line-height: 1.3;
    letter-spacing: var(--ds-tracking-tight);
    color: var(--ds-text);
}
.ds-overlay-subtitle {
    margin: 4px 0 0;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-medium);
    line-height: 1.4;
    color: var(--ds-text-muted);
}
.ds-overlay-header .ds-icon-btn { margin-top: -2px; margin-inline-end: -6px; }
.ds-overlay-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    flex-shrink: 0;
    gap: var(--ds-space-2);
    padding: 14px var(--ds-space-5);
    border-top: 1px solid var(--ds-border);
    background: var(--ds-surface-subtle);
}
.ds-overlay-footer--split > :first-child { margin-inline-end: auto; }
.ds-overlay-footer__note { flex-basis: 100%; margin: 0; font-size: var(--ds-fs-small); color: var(--ds-text-muted); }
.ds-overlay-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; margin: 0; }

.ds-modal {
    position: fixed;
    inset: 0;
    z-index: var(--ds-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-4);
    color: var(--ds-text-2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--ds-dur) ease, visibility var(--ds-dur) ease;
}
.ds-modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.ds-modal__backdrop,
.ds-drawer__backdrop {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--ds-backdrop);
    cursor: pointer;
}
.ds-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: min(90vh, 900px);
    overflow: hidden;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-dialog);
    transform: translateY(8px) scale(0.98);
    transition: transform var(--ds-dur) var(--ds-ease);
}
.ds-modal.is-open .ds-modal__dialog { transform: none; }
.ds-modal__dialog:focus,
.ds-drawer__panel:focus { outline: none; }
.ds-modal--sm .ds-modal__dialog,
.ds-modal--confirm .ds-modal__dialog { max-width: 400px; }
.ds-modal--lg .ds-modal__dialog { max-width: 680px; }
.ds-modal--xl .ds-modal__dialog { max-width: 880px; }
.ds-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--ds-space-5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.ds-modal__body--flush { padding: 0; }
.ds-modal--confirm { z-index: var(--ds-z-confirm); }
.ds-modal--confirm .ds-modal__body { padding: 22px 22px 18px; }
.ds-modal--confirm .ds-overlay-title { margin-bottom: var(--ds-space-2); }
.ds-confirm__text {
    margin: 0 0 18px;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    line-height: 1.5;
    color: var(--ds-text-3);
}
.ds-confirm__input { width: 100%; margin-block-start: var(--ds-space-3); }
.ds-confirm__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--ds-space-2); }
@media (max-width: 575.98px) {
    .ds-modal:not(.ds-modal--confirm) { align-items: flex-end; padding: 0; }
    .ds-modal:not(.ds-modal--confirm) .ds-modal__dialog {
        max-width: 100%;
        max-height: min(92dvh, 100%);
        border-inline: 0;
        border-bottom: 0;
        border-radius: var(--ds-radius-xl) var(--ds-radius-xl) 0 0;
        transform: translateY(24px);
    }
    .ds-modal.is-open:not(.ds-modal--confirm) .ds-modal__dialog { transform: none; }
    .ds-modal .ds-overlay-footer { padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
    .ds-modal .ds-overlay-footer--split { flex-direction: column-reverse; align-items: stretch; }
    .ds-modal .ds-overlay-footer--split > * { width: 100%; margin: 0; }
}

.ds-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--ds-z-drawer);
    display: flex;
    justify-content: flex-end;
    color: var(--ds-text-2);
    visibility: hidden;
    pointer-events: none;
    transition: visibility var(--ds-dur-slow);
}
.ds-drawer.is-open { visibility: visible; pointer-events: auto; }
.ds-drawer__backdrop { opacity: 0; transition: opacity var(--ds-dur-slow) ease; }
.ds-drawer.is-open .ds-drawer__backdrop { opacity: 1; }
.ds-drawer__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(440px, 100%);
    height: 100%;
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-drawer);
    transform: translateX(calc(100% * var(--ds-dir, 1)));
    transition: transform var(--ds-dur-slow) var(--ds-ease);
}
.ds-drawer--wide .ds-drawer__panel { width: min(560px, 100%); }
html[dir="rtl"] .ds-drawer__panel { transform: translateX(-100%); box-shadow: var(--ds-shadow-drawer-rtl); }
.ds-drawer.is-open .ds-drawer__panel { transform: none; }
.ds-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--ds-space-5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.ds-drawer .ds-overlay-footer { justify-content: flex-start; }
.ds-drawer .ds-overlay-footer > .ds-btn { flex: 1 1 auto; min-width: 0; }
.ds-section + .ds-section { margin-top: var(--ds-space-5); }
.ds-section__title {
    margin: 0 0 10px;
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-bold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
    color: var(--ds-text-muted);
}
.ds-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    margin-bottom: var(--ds-space-4);
    padding-bottom: var(--ds-space-4);
    border-bottom: 1px solid var(--ds-divider);
}
.ds-hero__title {
    margin: 0;
    font-size: var(--ds-fs-heading);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
    word-break: break-all;
}

/* ── 17. Content patterns ──────────────────────────────────────────────── */
/* Divider, optionally with a label ("or", a day in a conversation) */
.ds-divider {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    margin: var(--ds-space-4) 0;
    color: var(--ds-text-muted);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-medium);
}
.ds-divider::before,
.ds-divider::after { content: ""; flex: 1 1 0; height: 1px; background: var(--ds-divider); }
.ds-divider:empty { gap: 0; }
.ds-divider:empty::after { display: none; }

/* Rule builder: "Where / and / or" + field, operator, value + remove */
.ds-rules { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-rule {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-2);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-subtle);
}
.ds-rule__joint {
    font-size: var(--ds-fs-small);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-3);
}
.ds-rule__joint .ds-select { height: var(--ds-control-sm); min-height: var(--ds-control-sm); padding-inline: 8px 24px; background-position: right 8px center; font-size: var(--ds-fs-small); line-height: calc(var(--ds-control-sm) - 2px); }
html[dir="rtl"] .ds-rule__joint .ds-select { background-position: left 8px center; }
.ds-rule__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--ds-space-2);
    min-width: 0;
}
.ds-rules__add { align-self: flex-start; }
@media (max-width: 575.98px) {
    .ds-rule { grid-template-columns: minmax(0, 1fr) auto; }
    .ds-rule__joint { grid-column: 1 / -1; }
}

/* Date range: a trigger that reads like a field, presets + custom dates in a popover */
.ds-date-range { position: relative; display: inline-flex; max-width: 100%; }
.ds-date-range__trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-2);
    max-width: 100%;
    height: var(--ds-control-md);
    margin: 0;
    padding: 0 12px;
    padding-inline-end: 36px;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface) var(--ds-chevron) no-repeat right 14px center / 10px 7px;
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    white-space: nowrap;
    cursor: pointer;
}
html[dir="rtl"] .ds-date-range__trigger { background-position: left 14px center; }
.ds-date-range__trigger > i { font-size: var(--ds-icon-sm); color: var(--ds-text-muted); }
.ds-date-range__value { overflow: hidden; text-overflow: ellipsis; }
.ds-date-range__trigger:focus-visible,
.ds-date-range__trigger[aria-expanded="true"] { outline: none; border-color: var(--ds-brand-text); box-shadow: var(--ds-ring); }
.ds-date-range__panel { min-width: min(340px, calc(100vw - 32px)); }
.ds-date-range__presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.ds-date-range__preset {
    min-height: var(--ds-control-sm);
    margin: 0;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-2);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    text-align: start;
    cursor: pointer;
}
.ds-date-range__preset:hover { background: var(--ds-surface-sunken); color: var(--ds-text); }
.ds-date-range__preset:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: -2px; }
.ds-date-range__preset[aria-pressed="true"] { background: var(--ds-brand-soft); color: var(--ds-brand-text); font-weight: var(--ds-fw-semibold); }
.ds-date-range__custom {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--ds-space-2);
    margin-top: var(--ds-space-3);
    padding-top: var(--ds-space-3);
    border-top: 1px solid var(--ds-divider);
}

/* Charts: series colours in fixed order; text next to a mark stays in text colours */
.ds-series-1 { --ds-series: var(--ds-chart-1); }
.ds-series-2 { --ds-series: var(--ds-chart-2); }
.ds-series-3 { --ds-series: var(--ds-chart-3); }
.ds-series-4 { --ds-series: var(--ds-chart-4); }
.ds-series-5 { --ds-series: var(--ds-chart-5); }
.ds-series-6 { --ds-series: var(--ds-chart-6); }
.ds-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px var(--ds-space-4);
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--ds-font);
    font-size: var(--ds-fs-small);
    color: var(--ds-text-3);
}
.ds-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.ds-legend__swatch { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; background: var(--ds-series, var(--ds-chart-1)); }
.ds-legend__value { font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-sparkline { display: block; width: 100%; height: 32px; overflow: visible; color: var(--ds-series, var(--ds-chart-1)); }
.ds-sparkline--success { color: var(--ds-success-graphic); }
.ds-sparkline--danger { color: var(--ds-danger); }
.ds-sparkline__line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ds-sparkline__area { fill: currentColor; stroke: none; opacity: 0.12; }
/* Time runs left to right in every language, like the line version */
.ds-sparkbars { display: flex; align-items: flex-end; justify-content: space-between; gap: 2px; width: 100%; height: 32px; color: var(--ds-series, var(--ds-chart-1)); direction: ltr; }
.ds-sparkbars__bar { flex: 1 1 0; min-width: 2px; max-width: 28px; min-height: 2px; border-radius: 4px 4px 0 0; background: currentColor; opacity: 0.4; }
.ds-sparkbars__bar.is-latest { opacity: 1; }
.ds-kpi__spark { margin-top: var(--ds-space-2); }

/* Rating: read-only stars, or a radio group to rate */
.ds-rating { display: inline-flex; align-items: center; gap: 2px; color: var(--ds-warning-graphic); }
.ds-rating svg { display: block; width: 16px; height: 16px; fill: currentColor; }
.ds-rating .is-empty { fill: var(--ds-border-strong); }
.ds-rating__value { margin-inline-start: 6px; font-family: var(--ds-font); font-size: var(--ds-fs-small); font-weight: var(--ds-fw-semibold); color: var(--ds-text-2); }
.ds-rating-input {
    display: inline-flex;
    gap: 2px;
    margin: 0;
    padding: 0;
    border: 0;
}
.ds-rating-input input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.ds-rating-input label { display: inline-grid; place-items: center; width: var(--ds-control-sm); height: var(--ds-control-sm); border-radius: var(--ds-radius-sm); color: var(--ds-control-border); cursor: pointer; }
.ds-rating-input label svg { width: 22px; height: 22px; fill: currentColor; }
/* Stars stay in reading order (arrow keys move the way they look): the chosen star and the ones before it fill */
.ds-rating-input label:has(~ input:checked),
.ds-rating-input input:checked + label,
.ds-rating-input label:hover,
.ds-rating-input label:has(~ label:hover) { color: var(--ds-warning-graphic); }
.ds-rating-input input:focus-visible + label { outline: 2px solid var(--ds-brand-text); outline-offset: -2px; }

/* Image / avatar input: preview, then Change and Remove */
.ds-image-input { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-3) var(--ds-space-4); }
.ds-image-input__preview {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid var(--ds-border);
    border-radius: 50%;
    background: var(--ds-surface-sunken);
    color: var(--ds-text-muted);
    font-size: var(--ds-icon-lg);
}
.ds-image-input--square .ds-image-input__preview { border-radius: var(--ds-radius-lg); }
.ds-image-input--lg .ds-image-input__preview { width: 112px; height: 112px; font-size: var(--ds-icon-xl); }
.ds-image-input__preview img { width: 100%; height: 100%; object-fit: cover; }
.ds-image-input__preview img[hidden],
.ds-image-input__preview.has-image > i { display: none; }
.ds-image-input__text { display: flex; flex-direction: column; gap: var(--ds-space-2); min-width: 0; }
.ds-image-input__actions { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); }
.ds-image-input__hint { margin: 0; font-size: var(--ds-fs-small); color: var(--ds-text-muted); }
.ds-image-input__file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ds-image-input label.ds-btn:focus-within { outline: 2px solid var(--ds-brand-text); outline-offset: 2px; }

/* Conversation: bubbles in and out, delivery status, day dividers, system notes */
.ds-chat { display: flex; flex-direction: column; gap: var(--ds-space-3); padding: var(--ds-space-4); font-family: var(--ds-font); }
.ds-chat > .ds-divider { margin: var(--ds-space-2) 0; }
.ds-msg { display: flex; align-items: flex-end; gap: var(--ds-space-2); max-width: min(80%, 560px); }
.ds-msg--out { align-self: flex-end; flex-direction: row-reverse; }
.ds-msg__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ds-msg--out .ds-msg__body { align-items: flex-end; }
.ds-msg__author { font-size: var(--ds-fs-caption); font-weight: var(--ds-fw-semibold); color: var(--ds-text-3); }
.ds-msg__bubble {
    padding: 8px 12px;
    border-radius: 14px;
    border-end-start-radius: 4px;
    background: var(--ds-surface-sunken);
    color: var(--ds-text);
    font-size: var(--ds-fs-body-lg);
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.ds-msg--out .ds-msg__bubble { border-end-start-radius: 14px; border-end-end-radius: 4px; background: var(--ds-brand); color: var(--ds-text-on-brand); }
.ds-msg--out .ds-msg__bubble a { color: inherit; text-decoration: underline; }
.ds-msg__meta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--ds-fs-caption); color: var(--ds-text-muted); }
.ds-msg__meta > i { font-size: var(--ds-icon-xs); }
.ds-msg__meta .is-read { color: var(--ds-info-text); }
.ds-msg__meta .is-failed { color: var(--ds-danger-text); }
.ds-msg--note { align-self: center; max-width: 90%; }
.ds-msg--note .ds-msg__bubble { padding: 4px 12px; border: 1px dashed var(--ds-border-strong); border-radius: var(--ds-radius-pill); background: transparent; color: var(--ds-text-3); font-size: var(--ds-fs-small); text-align: center; }

.ds-composer {
    display: flex;
    align-items: flex-end;
    gap: var(--ds-space-2);
    padding: 6px;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
}
.ds-composer:focus-within { border-color: var(--ds-brand-text); box-shadow: var(--ds-ring); }
.ds-composer__input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--ds-control-md);
    max-height: 200px;
    margin: 0;
    padding: 9px 6px;
    border: 0;
    background: transparent;
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body-lg);
    line-height: 1.45;
    resize: none;
}
.ds-composer__input:focus { outline: none; }
.ds-composer__input::placeholder { color: var(--ds-text-muted); }
.ds-composer__tools { display: flex; flex: 0 0 auto; gap: 2px; }
html[dir="rtl"] .ds-composer [icon-name="send-2"] { transform: scaleX(-1); }

/* WhatsApp preview: a phone screen with the template as the customer will see it */
.ds-wa { width: 100%; max-width: 340px; padding: 8px; border-radius: 30px; background: var(--ds-wa-frame); box-shadow: var(--ds-shadow-dialog); }
.ds-wa__screen { overflow: hidden; border-radius: 23px; background: var(--ds-wa-wallpaper); color: var(--ds-wa-text); font-family: var(--ds-font); }
.ds-wa__head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ds-wa-header); }
.ds-wa__head .ds-avatar { flex: 0 0 auto; }
.ds-wa__who { display: flex; flex-direction: column; min-width: 0; }
.ds-wa__name { overflow: hidden; font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); text-overflow: ellipsis; white-space: nowrap; }
.ds-wa__sub { font-size: var(--ds-fs-caption); color: var(--ds-wa-meta); }
.ds-wa__body { display: flex; flex-direction: column; gap: 4px; min-height: 240px; padding: 16px 12px 20px; }
.ds-wa__msg { display: flex; flex-direction: column; gap: 2px; align-self: flex-start; width: 88%; }
.ds-wa__bubble { padding: 4px; border-radius: 10px; border-start-start-radius: 2px; background: var(--ds-wa-bubble); box-shadow: var(--ds-shadow-xs); }
.ds-wa__media { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 7px; background: var(--ds-wa-wallpaper); object-fit: cover; }
.ds-wa__media--empty { display: grid; place-items: center; color: var(--ds-wa-meta); font-size: var(--ds-icon-xl); }
.ds-wa__doc { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 7px; background: var(--ds-wa-wallpaper); font-size: var(--ds-fs-small); }
.ds-wa__doc > i { font-size: var(--ds-icon-lg); color: var(--ds-danger); }
.ds-wa__title { padding: 6px 6px 0; font-size: var(--ds-fs-body-lg); font-weight: var(--ds-fw-bold); overflow-wrap: anywhere; }
.ds-wa__text { padding: 4px 6px 0; font-size: var(--ds-fs-body-lg); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.ds-wa__footer { padding: 4px 6px 0; font-size: var(--ds-fs-small); color: var(--ds-wa-meta); }
.ds-wa__time { padding: 2px 6px 0; font-size: var(--ds-fs-micro); color: var(--ds-wa-meta); text-align: end; }
.ds-wa__button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px;
    border-radius: 10px;
    background: var(--ds-wa-bubble);
    box-shadow: var(--ds-shadow-xs);
    color: var(--ds-wa-link);
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
}
.ds-wa__button > i { font-size: var(--ds-icon-sm); }
.ds-wa__msg--out { align-self: flex-end; }
.ds-wa__msg--out .ds-wa__bubble { border-start-start-radius: 10px; border-start-end-radius: 2px; background: var(--ds-wa-bubble-out); }

/* Tag input: chips you add with Enter or a comma, remove with × or Backspace */
.ds-tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: var(--ds-control-md);
    padding: 4px 6px;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    cursor: text;
}
.ds-tag-input:focus-within { border-color: var(--ds-brand-text); box-shadow: var(--ds-ring); }
.ds-tag-input .ds-tag { gap: 2px; min-height: 24px; padding-inline-end: 2px; font-size: var(--ds-fs-small); }
.ds-tag-input .ds-tag > span { overflow: hidden; text-overflow: ellipsis; }
.ds-tag-input__field {
    flex: 1 0 120px;
    min-width: 0;
    height: calc(var(--ds-control-md) - 12px);
    margin: 0;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-body);
}
.ds-tag-input__field:focus { outline: none; }
.ds-tag-input__field::placeholder { color: var(--ds-text-muted); }
.ds-tag__remove {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--ds-radius-pill);
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.ds-tag__remove svg { width: 10px; height: 10px; }
.ds-tag__remove:hover { background: var(--ds-border); }
.ds-tag__remove:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 0; }

/* Code block with a copy button (API keys, webhooks, embed snippets) */
.ds-code { min-width: 0; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); background: var(--ds-surface-subtle); }
.ds-code pre:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: -2px; }
.ds-code__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-2);
    padding-block: 4px; padding-inline: 12px 4px;
    padding-inline: 12px 4px;
    border-bottom: 1px solid var(--ds-divider);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-bold);
    letter-spacing: var(--ds-tracking-caps);
    text-transform: uppercase;
    color: var(--ds-text-muted);
}
.ds-code pre {
    margin: 0;
    border-radius: 0 0 var(--ds-radius-md) var(--ds-radius-md);
    padding: 12px;
    overflow: auto;
    direction: ltr;
    color: var(--ds-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--ds-fs-small);
    line-height: 1.6;
    text-align: start;
    white-space: pre;
    tab-size: 2;
}

/* Notification row */
.ds-notif {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--ds-space-3);
    padding: var(--ds-space-3) var(--ds-space-4);
    border-radius: var(--ds-radius-md);
    color: var(--ds-text-2);
    font-family: var(--ds-font);
    text-decoration: none;
}
a.ds-notif:hover { background: var(--ds-surface-sunken); }
a.ds-notif:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: -2px; }
.ds-notif.is-unread { background: var(--ds-brand-softer); }
.ds-notif__body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.ds-notif__title { font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); color: var(--ds-text); }
.ds-notif__text { font-size: var(--ds-fs-small); color: var(--ds-text-3); overflow-wrap: anywhere; }
.ds-notif__time { font-size: var(--ds-fs-caption); color: var(--ds-text-muted); }
.ds-notif__dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--ds-brand); }

/* Avatar with presence */
.ds-avatar-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.ds-avatar__presence {
    position: absolute;
    inset-block-end: 0;
    inset-inline-end: 0;
    width: 10px;
    height: 10px;
    border: 2px solid var(--ds-surface);
    border-radius: 50%;
    background: var(--ds-text-subtle);
}
.ds-avatar__presence.is-online { background: var(--ds-success-graphic); }
.ds-avatar__presence.is-away { background: var(--ds-warning-graphic); }
.ds-avatar__presence.is-busy { background: var(--ds-danger); }

/* Media grid: image thumbnails and file tiles, optionally removable */
.ds-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--ds-space-2); margin: 0; padding: 0; list-style: none; }
.ds-media {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-sunken);
}
.ds-media > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ds-media--file { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: var(--ds-space-2); color: var(--ds-text-3); font-family: var(--ds-font); font-size: var(--ds-fs-caption); text-align: center; }
.ds-media--file > i { font-size: var(--ds-icon-lg); color: var(--ds-brand-text); }
.ds-media__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-media__remove {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ds-tooltip-bg);
    color: var(--ds-tooltip-text);
    cursor: pointer;
}
.ds-media__remove svg { width: 10px; height: 10px; }
.ds-media__remove:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 1px; }

/* ── 18. Responsive and touch ─────────────────────────────────────────── */
/*
 * Breakpoints (same as the app): phone < 576 · large phone / small tablet < 768 · tablet < 992 · desktop ≥ 992.
 * Layouts are intrinsic first (auto-fit grids, wrapping flex), so most components need no breakpoint at all.
 */

/* Phones: text one step larger for reading at arm's length; tighter chrome padding */
@media (max-width: 575.98px) {
    :root {
        --ds-fs-display: 20px;
        --ds-fs-metric: 20px;
        --ds-fs-title: 17px;
        --ds-fs-body-lg: 15px;
        --ds-fs-body: 14px;
        --ds-fs-small: 13px;
        --ds-fs-caption: 12px;
        --ds-fs-micro: 11px;
    }
    [lang|="ar"] {
        --ds-fs-body-lg: 16px;
        --ds-fs-body: 15px;
        --ds-fs-small: 14px;
        --ds-fs-caption: 13px;
        --ds-fs-micro: 12px;
    }
    .ds-overlay-header,
    .ds-overlay-footer { padding-inline: var(--ds-space-4); }
    .ds-modal__body,
    .ds-drawer__body { padding: var(--ds-space-4); }
    .ds-empty { padding: var(--ds-space-8) var(--ds-space-4); }
    .ds-toolbar { flex-basis: 100%; max-width: none; margin-inline-start: 0; }
    .ds-popover { min-width: min(300px, calc(100vw - 24px)); }
    .ds-banner { flex-wrap: wrap; }
    .ds-banner__body { flex: 1 1 200px; }
    .ds-toast-region {
        inset-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px));
        width: auto;
        align-items: stretch;
    }
    .ds-page-header__actions { width: 100%; }
    .ds-page-header__actions > .ds-btn { flex: 1 1 auto; }
}

/* Tablets and phones: keep toasts and the bulk bar above the docked primary action */
@media (max-width: 991.98px) {
    body:has(.ds-dock) .ds-toast-region,
    body:has(.ds-dock) .ds-bulkbar { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

/*
 * Touch screens: 40–48px targets (Fitts's law; Apple and Material ask 44–48px) and 16px text in fields,
 * below which iOS Safari zooms the page on focus.
 */
@media (pointer: coarse) {
    :root {
        --ds-control-sm: 40px;
        --ds-control-md: 44px;
        --ds-control-lg: 48px;
    }
    .ds-input,
    .ds-select,
    .ds-textarea,
    .ds-select-menu__trigger { font-size: max(16px, var(--ds-fs-body)); }
    .ds-switch__track { width: 44px; height: 26px; }
    .ds-switch__track::before { width: 22px; height: 22px; }
    .ds-switch input:checked + .ds-switch__track::before { transform: translateX(calc(18px * var(--ds-dir, 1))); }
    html[dir="rtl"] .ds-switch input:checked + .ds-switch__track::before { transform: translateX(-18px); }
    .ds-choice input[type="radio"] { width: 20px; height: 20px; }
    .ds-composer__input,
    .ds-tag-input__field,
    .ds-date-range__custom .ds-input { font-size: max(16px, var(--ds-fs-body)); }
    .ds-tag__remove { width: 28px; height: 28px; }
    .ds-media__remove { width: 32px; height: 32px; }
}

/*
 * Mixed direction: data (amounts, ids, phones, dates, codes) takes its direction from its own first letter,
 * so "184.50 TND", "#BB-10482" and "+12%" read correctly inside Arabic, and Arabic values read correctly in English.
 */
.ds-amount,
.ds-kpi__value,
.ds-kpi__trend,
.ds-cell__primary,
.ds-cell__meta,
.ds-person__name,
.ds-person__meta,
.ds-meta > *,
.ds-hero__title,
.ds-dl dd,
.ds-tabular,
.ds-timeline__time { unicode-bidi: plaintext; }
/* Isolated values still align with their page, not with their own direction (a number in an Arabic card stays on the right) */
:is(.ds-amount, .ds-kpi__value, .ds-cell__primary, .ds-cell__meta, .ds-person__name, .ds-person__meta, .ds-hero__title, .ds-dl dd, .ds-tabular) { text-align: start; }
:is(html[dir="rtl"], [dir="rtl"][lang|="ar"]) :is(.ds-amount, .ds-kpi__value, .ds-cell__primary, .ds-cell__meta, .ds-person__name, .ds-person__meta, .ds-hero__title, .ds-dl dd, .ds-tabular) { text-align: right; }
.ds-dl--inline dd { text-align: end; }
:is(html[dir="rtl"], [dir="rtl"][lang|="ar"]) .ds-dl--inline dd { text-align: left; }
.ds-table .ds-col-num :is(.ds-amount, .ds-tabular) { text-align: inherit; }
/* Always left-to-right: phone numbers, emails, URLs, keys, hex colors (aligned to the start of the line) */
.ds-ltr { direction: ltr; unicode-bidi: isolate; }
.ds-input[type="tel"],
.ds-input[type="email"],
.ds-input[type="url"],
.ds-copy .ds-input,
.ds-color .ds-input { unicode-bidi: plaintext; text-align: start; }
/* A phone field with its country code stays in reading order (+216 then the number) in Arabic too */
.ds-input-group--ltr { direction: ltr; }

/* Native date / time pickers: our icon shows, the browser's invisible button sits on top of it and opens the picker */
.ds-input-icon--end > .ds-input::-webkit-calendar-picker-indicator {
    position: absolute;
    inset-inline-end: 0;
    width: 40px;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

/* Long text (URLs, emails, file paths, API keys) wraps instead of pushing a page sideways; tables scroll instead */
.ds-page,
.ds-modal,
.ds-drawer,
.ds-popover,
.ds-toast-region { overflow-wrap: anywhere; }
.ds-table { overflow-wrap: normal; }
.ds-page-subtitle,
.ds-panel__subtitle { max-width: 72ch; }
.ds-page-title,
.ds-panel__title,
.ds-overlay-title,
.ds-empty__title,
.ds-card__title { overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
    .ds-modal, .ds-modal__dialog, .ds-drawer, .ds-drawer__panel, .ds-drawer__backdrop,
    .ds-popover, .ds-menu__list, .ds-select-menu__list, .ds-toast, .ds-tooltip, .ds-progress__bar {
        transition: none !important;
        animation: none !important;
    }
    .ds-skeleton { animation: none; }
    .ds-spinner, .ds-btn.is-loading::after, .ds-loading[aria-busy="true"]::after { animation-duration: 1.6s; }
}

/* Calendar: a month grid, with time when needed. ds.calendar() or BbDs.calendar(). */
.ds-calendar {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
    width: 100%;
    max-width: 360px;
    padding: var(--ds-space-4);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    color: var(--ds-text);
    font-family: var(--ds-font);
    overflow: visible;
}
.ds-calendar__grid.ds-calendar__grid--wide { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ds-calendar__cell {
    height: 44px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-2);
    font: inherit;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-medium);
    cursor: pointer;
}
.ds-calendar__cell:hover:not(:disabled) { background: var(--ds-surface-sunken); color: var(--ds-text); }
.ds-calendar__cell:disabled { color: var(--ds-text-subtle); cursor: not-allowed; }
.ds-calendar__cell.is-selected { background: var(--ds-brand); color: var(--ds-text-on-brand); }
.ds-calendar__cell:focus-visible,
button.ds-calendar__title:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 1px; }
button.ds-calendar__title { min-height: 32px; border: 0; border-radius: var(--ds-radius-sm); background: transparent; color: var(--ds-text); font-family: inherit; cursor: pointer; }
button.ds-calendar__title:hover { background: var(--ds-surface-sunken); }
.ds-calendar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2); }
.ds-calendar__title { flex: 1; font-size: var(--ds-fs-body-lg); font-weight: var(--ds-fw-semibold); text-align: center; }
.ds-calendar__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text-2);
    cursor: pointer;
}
.ds-calendar__nav .iconsax { font-size: var(--ds-icon-xs); }
.ds-calendar__nav:hover:not(:disabled) { background: var(--ds-surface-sunken); color: var(--ds-text); }
.ds-calendar__nav:disabled { color: var(--ds-text-subtle); cursor: not-allowed; }
.ds-calendar__weekdays,
.ds-calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.ds-calendar__weekday {
    overflow: hidden;
    padding-block: var(--ds-space-1);
    color: var(--ds-text-muted);
    font-size: var(--ds-fs-caption);
    font-weight: var(--ds-fw-semibold);
    text-align: center;
    white-space: nowrap;
}
.ds-calendar__day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 40px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text);
    font-family: inherit;
    font-size: var(--ds-fs-body);
    cursor: pointer;
}
.ds-calendar__day:hover:not(:disabled) { background: var(--ds-surface-sunken); }
.ds-calendar__day.is-outside { color: var(--ds-text-muted); }
.ds-calendar__day.is-today { box-shadow: inset 0 0 0 1px var(--ds-brand-line); color: var(--ds-brand-text); font-weight: var(--ds-fw-semibold); }
.ds-calendar__day.is-selected,
.ds-calendar__day.is-selected:hover:not(:disabled) { background: var(--ds-brand); box-shadow: none; color: var(--ds-text-on-brand); font-weight: var(--ds-fw-semibold); }
.ds-calendar__day:disabled { color: var(--ds-text-subtle); cursor: not-allowed; }
.ds-calendar__nav:focus-visible,
.ds-calendar__day:focus-visible { outline: 2px solid var(--ds-brand-text); outline-offset: 1px; }
.ds-calendar__time {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding-block-start: var(--ds-space-3);
    border-block-start: 1px solid var(--ds-divider);
}
.ds-calendar__time-label { display: inline-flex; align-items: center; gap: var(--ds-space-2); color: var(--ds-text-2); font-size: var(--ds-fs-body); font-weight: var(--ds-fw-semibold); }
.ds-calendar__time-fields { display: inline-flex; align-items: center; gap: var(--ds-space-1); direction: ltr; }
.ds-calendar__time-field {
    width: 56px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text);
    font-family: inherit;
    font-size: var(--ds-fs-body);
    font-variant-numeric: tabular-nums;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}
.ds-calendar__time-period {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 72px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--ds-control-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text);
    font-family: inherit;
    font-size: var(--ds-fs-body);
    font-weight: var(--ds-fw-semibold);
    text-align: center;
    cursor: pointer;
}
.ds-calendar__time-period:focus { border-color: var(--ds-brand-text); box-shadow: var(--ds-ring); outline: none; }
.ds-calendar__period-control { position: relative; display: inline-flex; }
.ds-calendar__period-chevron {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-block-start: -4px;
    border-inline-end: 2px solid var(--ds-text-2);
    border-block-end: 2px solid var(--ds-text-2);
    transform: rotate(45deg);
}
.ds-calendar__period-menu {
    position: absolute;
    z-index: 40;
    inset-inline-end: 0;
    /* The time row is the last thing in the calendar, usually at the bottom of a modal: open upward over the
       month grid so the menu is never clipped by the modal's lower edge. */
    inset-block-end: calc(100% + 6px);
    min-width: 100%;
    padding: 4px;
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-raised);
    box-shadow: var(--ds-shadow-lg, 0 12px 28px rgba(0, 0, 0, .28));
}
.ds-calendar__period-menu[hidden] { display: none; }
.ds-calendar__period-option {
    display: block;
    width: 100%;
    min-height: 34px;
    padding: 7px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ds-text-2);
    font: inherit;
    font-weight: var(--ds-fw-semibold);
    text-align: center;
    cursor: pointer;
}
.ds-calendar__period-option:hover,
.ds-calendar__period-option:focus-visible,
.ds-calendar__period-option.is-selected { background: var(--ds-brand-soft); color: var(--ds-brand-text); outline: none; }
.ds-calendar__time-field::-webkit-outer-spin-button,
.ds-calendar__time-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ds-calendar__time-field:focus { border-color: var(--ds-brand-text); box-shadow: var(--ds-ring); outline: none; }
.ds-calendar-modal .modal-dialog { max-width: 440px; }
.ds-calendar-modal .ds-calendar { max-width: none; border: 0; padding: 0; }
