/* ============================================================
   CREET DESIGN SYSTEM — COMPONENT PRIMITIVES
   ------------------------------------------------------------
   Every component uses tokens (var(--cds-*)) — NO hard-coded
   colors, spacing, or radii. Light/dark works automatically
   via tokens.css. NEVER add !important; if specificity is an
   issue, raise it with a parent selector instead.
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   1. PAGE LAYOUT
   ════════════════════════════════════════════════════════════ */
.cds-page {
    padding: var(--cds-space-6);
    max-width: 1440px;
    margin: 0 auto;
    color: var(--cds-text);
}
@media (max-width: 782px) { .cds-page { padding: var(--cds-space-3); } }

.cds-page-header {
    background: var(--cds-gradient-header);
    color: var(--cds-text-on-dark);
    border-radius: var(--cds-radius-xl);
    padding: var(--cds-space-6) var(--cds-space-7);
    margin-bottom: var(--cds-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cds-space-4);
    flex-wrap: wrap;
    box-shadow: var(--cds-shadow-lg);
    position: relative;
    overflow: hidden;
}
.cds-page-header::after {
    /* Subtle lime glow bleeding from one corner — gives the header
       a "lit-from-within" feel instead of a flat gradient.        */
    content: '';
    position: absolute;
    inset-inline-end: -80px;
    top: -80px;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, var(--cds-brand-soft-strong) 0%, transparent 60%);
    pointer-events: none;
}
.cds-page-header__title-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--cds-space-1);
    z-index: 1;
}
.cds-page-header__title {
    margin: 0;
    font-size: var(--cds-text-2xl);
    font-weight: var(--cds-weight-bold);
    line-height: var(--cds-leading-tight);
    color: var(--cds-text-on-dark);
    letter-spacing: var(--cds-tracking-tight);
}
.cds-page-header__subtitle {
    margin: 0;
    font-size: var(--cds-text-md);
    color: rgba(255, 255, 255, 0.65);
    font-weight: var(--cds-weight-normal);
}
.cds-page-header__actions {
    display: flex;
    gap: var(--cds-space-2);
    align-items: center;
    z-index: 1;
}
@media (max-width: 782px) {
    .cds-page-header {
        padding: var(--cds-space-4) var(--cds-space-4);
        border-radius: var(--cds-radius-lg);
    }
    .cds-page-header__title { font-size: var(--cds-text-xl); }
    .cds-page-header__actions { width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   2. CARD
   ════════════════════════════════════════════════════════════ */
.cds-card {
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-lg);
    box-shadow: var(--cds-shadow-sm);
    padding: var(--cds-space-5);
    color: var(--cds-text);
}
.cds-card--flat        { box-shadow: none; }
.cds-card--padded      { padding: var(--cds-space-6); }
.cds-card--compact     { padding: var(--cds-space-3); }
.cds-card--elevated    { box-shadow: var(--cds-shadow-md); }
.cds-card--interactive {
    cursor: pointer;
    transition: transform   var(--cds-duration-fast) var(--cds-ease),
                box-shadow  var(--cds-duration-fast) var(--cds-ease),
                border-color var(--cds-duration-fast) var(--cds-ease);
}
.cds-card--interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--cds-shadow-lg);
    border-color: var(--cds-border-strong);
}
.cds-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cds-space-3);
    padding-bottom: var(--cds-space-3);
    margin-bottom: var(--cds-space-4);
    border-bottom: 1px solid var(--cds-border-subtle);
}
.cds-card__title {
    font-size: var(--cds-text-lg);
    font-weight: var(--cds-weight-semibold);
    color: var(--cds-text);
    margin: 0;
    line-height: var(--cds-leading-snug);
}
.cds-card__subtitle {
    font-size: var(--cds-text-sm);
    color: var(--cds-text-muted);
    margin: var(--cds-space-1) 0 0;
}

/* ════════════════════════════════════════════════════════════
   3. STAT (label + value + trend)
   ════════════════════════════════════════════════════════════ */
.cds-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--cds-space-4);
    margin-bottom: var(--cds-space-6);
}
@media (max-width: 782px) {
    .cds-stat-grid { grid-template-columns: 1fr; gap: var(--cds-space-3); }
}

.cds-stat {
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-lg);
    padding: var(--cds-space-5);
    box-shadow: var(--cds-shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--cds-space-2);
    position: relative;
    overflow: hidden;
    transition: transform var(--cds-duration-fast) var(--cds-ease),
                box-shadow var(--cds-duration-fast) var(--cds-ease);
}
.cds-stat:hover {
    transform: translateY(-1px);
    box-shadow: var(--cds-shadow-md);
}
.cds-stat__label {
    font-size: var(--cds-text-sm);
    color: var(--cds-text-muted);
    font-weight: var(--cds-weight-medium);
    text-transform: uppercase;
    letter-spacing: var(--cds-tracking-wide);
    margin: 0;
}
.cds-stat__value {
    font-size: var(--cds-text-3xl);
    font-weight: var(--cds-weight-bold);
    color: var(--cds-text);
    line-height: var(--cds-leading-tight);
    letter-spacing: var(--cds-tracking-tight);
    font-feature-settings: 'tnum' 1, 'lnum' 1;
}
.cds-stat__hint {
    font-size: var(--cds-text-xs);
    color: var(--cds-text-subtle);
}
.cds-stat__trend {
    display: inline-flex;
    align-items: center;
    gap: var(--cds-space-1);
    font-size: var(--cds-text-xs);
    font-weight: var(--cds-weight-semibold);
    padding: 2px var(--cds-space-2);
    border-radius: var(--cds-radius-pill);
    width: fit-content;
}
.cds-stat__trend--up   { color: var(--cds-success-fg); background: var(--cds-success-bg); }
.cds-stat__trend--down { color: var(--cds-danger-fg);  background: var(--cds-danger-bg); }
.cds-stat__trend--flat { color: var(--cds-neutral-fg); background: var(--cds-neutral-bg); }
.cds-stat__icon {
    position: absolute;
    top: var(--cds-space-4);
    inset-inline-end: var(--cds-space-4);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--cds-radius-md);
    background: var(--cds-brand-soft);
    color: var(--cds-brand-deep);
}
body.creet-dark .cds-stat__icon { color: var(--cds-brand); }

/* ════════════════════════════════════════════════════════════
   4. BUTTON
   ════════════════════════════════════════════════════════════ */
.cds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--cds-space-2);
    height: var(--cds-btn-height);
    padding: 0 var(--cds-space-4);
    font-family: var(--cds-font-body);
    font-size: var(--cds-text-md);
    font-weight: var(--cds-weight-semibold);
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--cds-radius-md);
    background: var(--cds-bg-surface);
    color: var(--cds-text);
    cursor: pointer;
    transition: all var(--cds-duration-fast) var(--cds-ease);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
}
.cds-btn svg { flex-shrink: 0; }
.cds-btn:focus-visible {
    outline: none;
    box-shadow: var(--cds-shadow-focus);
}

/* Variants */
.cds-btn--primary {
    background: var(--cds-brand);
    border-color: var(--cds-brand-bold);
    color: var(--cds-text-on-brand);
    box-shadow: var(--cds-shadow-brand);
}
.cds-btn--primary:hover {
    background: var(--cds-brand-bold);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(195, 253, 115, 0.45);
}
.cds-btn--primary:active { transform: translateY(0); box-shadow: var(--cds-shadow-brand); }

.cds-btn--secondary {
    background: var(--cds-bg-surface);
    border-color: var(--cds-border);
    color: var(--cds-text);
    box-shadow: var(--cds-shadow-xs);
}
.cds-btn--secondary:hover {
    background: var(--cds-bg-surface-2);
    border-color: var(--cds-border-strong);
    color: var(--cds-text);
}

.cds-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--cds-text);
}
.cds-btn--ghost:hover {
    background: var(--cds-bg-surface-2);
    color: var(--cds-text);
}

.cds-btn--danger {
    background: var(--cds-danger);
    border-color: var(--cds-danger);
    color: #fff;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.28);
}
.cds-btn--danger:hover { background: #b91c1c; border-color: #b91c1c; transform: translateY(-1px); }

.cds-btn--inverse {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.20);
    color: var(--cds-text-on-dark);
    backdrop-filter: blur(6px);
}
.cds-btn--inverse:hover { background: rgba(255, 255, 255, 0.20); color: var(--cds-text-on-dark); }

/* Sizes */
.cds-btn--sm { height: var(--cds-btn-height-sm); padding: 0 var(--cds-space-3); font-size: var(--cds-text-sm); border-radius: var(--cds-radius-sm); }
.cds-btn--lg { height: var(--cds-btn-height-lg); padding: 0 var(--cds-space-5); font-size: var(--cds-text-lg); border-radius: var(--cds-radius-lg); }

.cds-btn--block { width: 100%; }
.cds-btn--icon  { width: var(--cds-btn-height); padding: 0; }
.cds-btn--icon.cds-btn--sm { width: var(--cds-btn-height-sm); }
.cds-btn--icon.cds-btn--lg { width: var(--cds-btn-height-lg); }

/* States */
.cds-btn[disabled],
.cds-btn--disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
}

.cds-btn--loading {
    color: transparent !important;
    pointer-events: none;
    position: relative;
}
.cds-btn--loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 16px; height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: cds-spin 0.7s linear infinite;
    color: var(--cds-text-on-brand);
}
.cds-btn--secondary.cds-btn--loading::after,
.cds-btn--ghost.cds-btn--loading::after { color: var(--cds-text); }
.cds-btn--danger.cds-btn--loading::after { color: #fff; }

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

/* Button group */
.cds-btn-group {
    display: inline-flex;
    gap: var(--cds-space-2);
}

/* ════════════════════════════════════════════════════════════
   5. BADGE / PILL / TAG
   ════════════════════════════════════════════════════════════ */
.cds-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--cds-space-1);
    padding: 3px var(--cds-space-2);
    font-size: var(--cds-text-xs);
    font-weight: var(--cds-weight-semibold);
    line-height: 1.4;
    border-radius: var(--cds-radius-sm);
    background: var(--cds-neutral-bg);
    color: var(--cds-neutral-fg);
    border: 1px solid var(--cds-neutral-border);
    white-space: nowrap;
}
.cds-badge--success { background: var(--cds-success-bg); color: var(--cds-success-fg); border-color: var(--cds-success-border); }
.cds-badge--warning { background: var(--cds-warning-bg); color: var(--cds-warning-fg); border-color: var(--cds-warning-border); }
.cds-badge--danger  { background: var(--cds-danger-bg);  color: var(--cds-danger-fg);  border-color: var(--cds-danger-border); }
.cds-badge--info    { background: var(--cds-info-bg);    color: var(--cds-info-fg);    border-color: var(--cds-info-border); }
.cds-badge--brand   { background: var(--cds-brand);      color: var(--cds-text-on-brand); border-color: var(--cds-brand-bold); }
.cds-badge--neutral { background: var(--cds-neutral-bg); color: var(--cds-neutral-fg); border-color: var(--cds-neutral-border); }
.cds-badge--solid   { padding: 4px var(--cds-space-3); }
.cds-badge--pill    { border-radius: var(--cds-radius-pill); }
.cds-badge__dot     { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ════════════════════════════════════════════════════════════
   6. TABLE
   ════════════════════════════════════════════════════════════ */
.cds-table-wrap {
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-lg);
    overflow: hidden;
    box-shadow: var(--cds-shadow-sm);
}
.cds-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cds-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--cds-text);
    font-size: var(--cds-text-md);
}
.cds-table thead th {
    background: var(--cds-bg-inverse);
    color: var(--cds-brand);
    font-size: var(--cds-text-xs);
    font-weight: var(--cds-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--cds-tracking-wide);
    padding: var(--cds-space-3) var(--cds-space-4);
    text-align: start;
    border-bottom: 1px solid var(--cds-border);
    white-space: nowrap;
}
body.creet-dark .cds-table thead th { background: #050810; }
.cds-table tbody td {
    padding: var(--cds-space-3) var(--cds-space-4);
    border-bottom: 1px solid var(--cds-border-subtle);
    vertical-align: middle;
    color: var(--cds-text);
}
.cds-table tbody tr:last-child td { border-bottom: none; }
.cds-table tbody tr {
    transition: background var(--cds-duration-fast) var(--cds-ease);
}
.cds-table tbody tr:hover td { background: var(--cds-bg-surface-2); }
.cds-table--striped tbody tr:nth-child(even) td { background: var(--cds-bg-surface-2); }
.cds-table--striped tbody tr:nth-child(even):hover td { background: var(--cds-bg-surface-3); }
.cds-table--compact tbody td,
.cds-table--compact thead th { padding: var(--cds-space-2) var(--cds-space-3); }

.cds-table__actions {
    display: inline-flex;
    gap: var(--cds-space-1);
}

/* Mobile: hide cds-table-wrap shadow on small screens to save room */
@media (max-width: 782px) {
    .cds-table-wrap { border-radius: var(--cds-radius-md); }
    .cds-table tbody td,
    .cds-table thead th { padding: var(--cds-space-2) var(--cds-space-3); font-size: var(--cds-text-sm); }
}

/* ════════════════════════════════════════════════════════════
   7. INPUT / FORM
   ════════════════════════════════════════════════════════════ */
.cds-field {
    display: flex;
    flex-direction: column;
    gap: var(--cds-space-1);
}
.cds-field--row {
    flex-direction: row;
    align-items: center;
    gap: var(--cds-space-2);
}
.cds-label {
    font-size: var(--cds-text-sm);
    font-weight: var(--cds-weight-semibold);
    color: var(--cds-text);
}
.cds-label__required {
    color: var(--cds-danger);
    margin-inline-start: 2px;
}
.cds-help {
    font-size: var(--cds-text-xs);
    color: var(--cds-text-muted);
    line-height: var(--cds-leading-snug);
    margin-top: var(--cds-space-1);
}
.cds-error {
    font-size: var(--cds-text-xs);
    color: var(--cds-danger);
    line-height: var(--cds-leading-snug);
    margin-top: var(--cds-space-1);
}

.cds-input,
.cds-select,
.cds-textarea {
    height: var(--cds-input-height);
    padding: 0 var(--cds-space-3);
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-md);
    color: var(--cds-text);
    font-family: var(--cds-font-body);
    font-size: var(--cds-text-md);
    line-height: var(--cds-leading-normal);
    transition: border-color var(--cds-duration-fast) var(--cds-ease),
                box-shadow   var(--cds-duration-fast) var(--cds-ease);
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
}
.cds-textarea { height: auto; min-height: 96px; padding: var(--cds-space-3); resize: vertical; line-height: var(--cds-leading-normal); }
.cds-input::placeholder, .cds-textarea::placeholder { color: var(--cds-text-subtle); }
.cds-input:hover, .cds-select:hover, .cds-textarea:hover { border-color: var(--cds-border-strong); }
.cds-input:focus, .cds-select:focus, .cds-textarea:focus {
    outline: none;
    border-color: var(--cds-brand-bold);
    box-shadow: var(--cds-shadow-focus);
}
.cds-input[disabled], .cds-select[disabled], .cds-textarea[disabled] {
    background: var(--cds-bg-surface-2);
    color: var(--cds-text-disabled);
    cursor: not-allowed;
}
.cds-input--error, .cds-select--error, .cds-textarea--error {
    border-color: var(--cds-danger);
}
.cds-input--error:focus, .cds-select--error:focus, .cds-textarea--error:focus {
    box-shadow: var(--cds-shadow-focus-danger);
}

.cds-input-group {
    display: flex;
    align-items: center;
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-md);
    overflow: hidden;
    transition: border-color var(--cds-duration-fast) var(--cds-ease),
                box-shadow   var(--cds-duration-fast) var(--cds-ease);
}
.cds-input-group:focus-within { border-color: var(--cds-brand-bold); box-shadow: var(--cds-shadow-focus); }
.cds-input-group .cds-input { border: none; box-shadow: none; }
.cds-input-group .cds-input:focus { box-shadow: none; }
.cds-input-group__icon {
    padding: 0 var(--cds-space-3);
    color: var(--cds-text-muted);
    display: grid;
    place-items: center;
}

/* Toggle switch */
.cds-switch {
    --switch-w: 40px;
    --switch-h: 22px;
    --knob: 18px;
    position: relative;
    display: inline-block;
    width: var(--switch-w);
    height: var(--switch-h);
    flex-shrink: 0;
}
.cds-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.cds-switch__slider {
    position: absolute; inset: 0;
    background: var(--cds-border-strong);
    border-radius: var(--cds-radius-pill);
    cursor: pointer;
    transition: background var(--cds-duration-fast) var(--cds-ease);
}
.cds-switch__slider::before {
    content: '';
    position: absolute;
    top: 2px; inset-inline-start: 2px;
    width: var(--knob);
    height: var(--knob);
    background: #fff;
    border-radius: var(--cds-radius-pill);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform var(--cds-duration-base) var(--cds-ease);
}
.cds-switch input:checked + .cds-switch__slider { background: var(--cds-brand); }
.cds-switch input:checked + .cds-switch__slider::before {
    transform: translateX(calc(var(--switch-w) - var(--knob) - 4px));
}
html[dir="rtl"] .cds-switch input:checked + .cds-switch__slider::before {
    transform: translateX(calc(-1 * (var(--switch-w) - var(--knob) - 4px)));
}
.cds-switch input:focus-visible + .cds-switch__slider { box-shadow: var(--cds-shadow-focus); }
.cds-switch input:disabled + .cds-switch__slider { opacity: 0.5; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════════
   8. TABS
   ════════════════════════════════════════════════════════════ */
.cds-tabs {
    display: flex;
    gap: var(--cds-space-1);
    border-bottom: 1px solid var(--cds-border);
    margin-bottom: var(--cds-space-5);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.cds-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--cds-space-2);
    padding: var(--cds-space-3) var(--cds-space-4);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--cds-text-muted);
    font-family: var(--cds-font-body);
    font-size: var(--cds-text-md);
    font-weight: var(--cds-weight-medium);
    cursor: pointer;
    transition: color var(--cds-duration-fast) var(--cds-ease),
                border-color var(--cds-duration-fast) var(--cds-ease);
    text-decoration: none;
    white-space: nowrap;
    margin-bottom: -1px;
}
.cds-tab:hover { color: var(--cds-text); }
.cds-tab--active {
    color: var(--cds-text);
    border-bottom-color: var(--cds-brand);
    font-weight: var(--cds-weight-semibold);
}
.cds-tab__count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background: var(--cds-bg-surface-2);
    color: var(--cds-text-muted);
    border-radius: var(--cds-radius-pill);
    font-size: var(--cds-text-xs);
    font-weight: var(--cds-weight-semibold);
}
.cds-tab--active .cds-tab__count {
    background: var(--cds-brand-soft-strong);
    color: var(--cds-text);
}

/* ════════════════════════════════════════════════════════════
   9. EMPTY STATE
   ════════════════════════════════════════════════════════════ */
.cds-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--cds-space-12) var(--cds-space-6);
    color: var(--cds-text-muted);
    gap: var(--cds-space-3);
}
.cds-empty__icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: var(--cds-radius-pill);
    background: var(--cds-bg-surface-2);
    color: var(--cds-text-subtle);
    margin-bottom: var(--cds-space-2);
}
.cds-empty__title {
    color: var(--cds-text);
    font-size: var(--cds-text-lg);
    font-weight: var(--cds-weight-semibold);
    margin: 0;
}
.cds-empty__desc {
    color: var(--cds-text-muted);
    font-size: var(--cds-text-md);
    max-width: 400px;
    line-height: var(--cds-leading-relaxed);
    margin: 0;
}
.cds-empty__actions {
    margin-top: var(--cds-space-3);
    display: flex;
    gap: var(--cds-space-2);
}

/* ════════════════════════════════════════════════════════════
   10. MODAL
   ════════════════════════════════════════════════════════════ */
.cds-modal {
    position: fixed;
    inset: 0;
    z-index: var(--cds-z-modal);
    display: grid;
    place-items: center;
    padding: var(--cds-space-4);
    background: var(--cds-bg-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: cds-fade-in var(--cds-duration-base) var(--cds-ease);
}
.cds-modal[hidden] { display: none !important; }
.cds-modal__panel {
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-xl);
    box-shadow: var(--cds-shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - var(--cds-space-8));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cds-modal-in var(--cds-duration-base) var(--cds-ease);
}
.cds-modal__panel--lg  { max-width: 720px; }
.cds-modal__panel--xl  { max-width: 960px; }
.cds-modal__panel--sm  { max-width: 400px; }

.cds-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cds-space-3);
    padding: var(--cds-space-4) var(--cds-space-5);
    border-bottom: 1px solid var(--cds-border-subtle);
}
.cds-modal__title {
    font-size: var(--cds-text-lg);
    font-weight: var(--cds-weight-semibold);
    color: var(--cds-text);
    margin: 0;
}
.cds-modal__close {
    background: transparent;
    border: none;
    color: var(--cds-text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--cds-radius-md);
    transition: all var(--cds-duration-fast) var(--cds-ease);
}
.cds-modal__close:hover { background: var(--cds-bg-surface-2); color: var(--cds-text); }
.cds-modal__body {
    padding: var(--cds-space-5);
    overflow-y: auto;
    color: var(--cds-text);
}
.cds-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--cds-space-2);
    padding: var(--cds-space-4) var(--cds-space-5);
    border-top: 1px solid var(--cds-border-subtle);
    background: var(--cds-bg-surface-2);
}

@keyframes cds-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes cds-modal-in  {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ════════════════════════════════════════════════════════════
   11. VIEW TOGGLE (table / grid) — required by CLAUDE.md
   ════════════════════════════════════════════════════════════ */
.cds-view-toggle {
    display: inline-flex;
    background: var(--cds-bg-surface-2);
    border: 1px solid var(--cds-border);
    border-radius: var(--cds-radius-md);
    padding: 3px;
    gap: 0;
}
.cds-view-toggle__btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--cds-text-muted);
    cursor: pointer;
    border-radius: var(--cds-radius-sm);
    transition: all var(--cds-duration-fast) var(--cds-ease);
}
.cds-view-toggle__btn:hover { color: var(--cds-text); }
.cds-view-toggle__btn--active {
    background: var(--cds-bg-surface);
    color: var(--cds-text);
    box-shadow: var(--cds-shadow-xs);
}

/* ════════════════════════════════════════════════════════════
   12. DIVIDER + AVATAR + AUX
   ════════════════════════════════════════════════════════════ */
.cds-divider {
    height: 1px;
    background: var(--cds-border);
    border: none;
    margin: var(--cds-space-4) 0;
}
.cds-divider--vertical {
    width: 1px;
    height: auto;
    align-self: stretch;
    margin: 0 var(--cds-space-3);
}

.cds-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--cds-radius-pill);
    background: var(--cds-bg-surface-2);
    color: var(--cds-text);
    display: grid;
    place-items: center;
    font-weight: var(--cds-weight-semibold);
    font-size: var(--cds-text-sm);
    overflow: hidden;
    flex-shrink: 0;
}
.cds-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cds-avatar--sm { width: 24px; height: 24px; font-size: var(--cds-text-xs); }
.cds-avatar--lg { width: 48px; height: 48px; font-size: var(--cds-text-lg); }
.cds-avatar--xl { width: 64px; height: 64px; font-size: var(--cds-text-xl); }

/* ════════════════════════════════════════════════════════════
   13. SKELETON (loading placeholder)
   ════════════════════════════════════════════════════════════ */
.cds-skeleton {
    background: linear-gradient(90deg,
                var(--cds-bg-surface-2) 0%,
                var(--cds-bg-surface-3) 50%,
                var(--cds-bg-surface-2) 100%);
    background-size: 200% 100%;
    animation: cds-skeleton 1.4s ease-in-out infinite;
    border-radius: var(--cds-radius-sm);
}
@keyframes cds-skeleton {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}
.cds-skeleton--text   { height: 14px; margin: 6px 0; }
.cds-skeleton--title  { height: 22px; margin: 8px 0; max-width: 60%; }
.cds-skeleton--avatar { width: 36px; height: 36px; border-radius: 50%; }

/* ════════════════════════════════════════════════════════════
   14. TOAST
   ════════════════════════════════════════════════════════════ */
.cds-toast-stack {
    position: fixed;
    bottom: var(--cds-space-5);
    inset-inline-end: var(--cds-space-5);
    z-index: var(--cds-z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--cds-space-2);
    pointer-events: none;
    max-width: 360px;
}
.cds-toast {
    background: var(--cds-bg-surface);
    border: 1px solid var(--cds-border);
    border-inline-start: 4px solid var(--cds-neutral);
    border-radius: var(--cds-radius-md);
    padding: var(--cds-space-3) var(--cds-space-4);
    box-shadow: var(--cds-shadow-lg);
    color: var(--cds-text);
    font-size: var(--cds-text-md);
    display: flex;
    align-items: flex-start;
    gap: var(--cds-space-2);
    pointer-events: auto;
    animation: cds-toast-in var(--cds-duration-base) var(--cds-ease-spring);
}
.cds-toast--success { border-inline-start-color: var(--cds-success); }
.cds-toast--warning { border-inline-start-color: var(--cds-warning); }
.cds-toast--danger  { border-inline-start-color: var(--cds-danger); }
.cds-toast--info    { border-inline-start-color: var(--cds-info); }
@keyframes cds-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════
   15. UTILITIES — sparing, only the ones used constantly
   ════════════════════════════════════════════════════════════ */
.cds-stack       { display: flex; flex-direction: column; gap: var(--cds-space-3); }
.cds-stack--sm   { gap: var(--cds-space-2); }
.cds-stack--lg   { gap: var(--cds-space-5); }
.cds-row         { display: flex; align-items: center; gap: var(--cds-space-2); }
.cds-row--between{ justify-content: space-between; }
.cds-row--end    { justify-content: flex-end; }
.cds-row--wrap   { flex-wrap: wrap; }
.cds-spacer     { flex: 1; }
.cds-truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cds-mono       { font-family: var(--cds-font-mono); font-feature-settings: 'tnum' 1; }
.cds-text-muted   { color: var(--cds-text-muted); }
.cds-text-subtle  { color: var(--cds-text-subtle); }
.cds-text-success { color: var(--cds-success-fg); }
.cds-text-danger  { color: var(--cds-danger-fg); }
.cds-text-warning { color: var(--cds-warning-fg); }
.cds-text-brand   { color: var(--cds-brand-deep); }
body.creet-dark .cds-text-brand { color: var(--cds-brand); }
.cds-hide-mobile { display: initial; }
.cds-show-mobile { display: none; }
@media (max-width: 782px) {
    .cds-hide-mobile { display: none !important; }
    .cds-show-mobile { display: initial; }
}

/* ════════════════════════════════════════════════════════════
   16. FLOATING SAVE BAR — opt-in pattern for long scrolling pages
   ------------------------------------------------------------
   Usage: wrap the page's save button(s) in
       <div class="cds-floating-save"> ... </div>
   The bar pins to the bottom-end, uses a pill shape, soft elevation
   and a backdrop blur so it reads as "floating" not "stuck-on".

   Body auto-reserves bottom padding via :has() so the bar never
   overlaps real content. No JS needed.
   ════════════════════════════════════════════════════════════ */
.cds-floating-save {
    position: fixed;
    bottom: var(--cds-space-6);
    inset-inline-end: var(--cds-space-6);
    z-index: var(--cds-z-sticky);
    display: inline-flex;
    align-items: center;
    gap: var(--cds-space-2);
    /* Bare wrapper — the button inside provides its own chrome. No
       container bg/border/shadow so it doesn't read as a "tray".  */
    background: transparent;
    border: 0;
    padding: 0;
    animation: cds-floating-save-in var(--cds-duration-base) var(--cds-ease-out);
}
@keyframes cds-floating-save-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Children — buttons inside the bar inherit a pill shape so they read
   as a unified control, not a row of square WP buttons.          */
.cds-floating-save > button,
.cds-floating-save > a,
.cds-floating-save .cds-btn,
.cds-floating-save .button,
.cds-floating-save .button-primary {
    border-radius: var(--cds-radius-pill);
    padding-inline: var(--cds-space-5);
    min-height: 38px;
    box-shadow: none;
}
.cds-floating-save > button:hover,
.cds-floating-save .cds-btn:hover,
.cds-floating-save .button-primary:hover {
    transform: translateY(-1px);
}

/* Hint label (optional) — small "Unsaved changes" text before the
   button. Goes inside the bar:
       <span class="cds-floating-save__hint">...</span>           */
.cds-floating-save__hint {
    padding-inline: var(--cds-space-3);
    font-size: var(--cds-text-sm);
    color: var(--cds-text-muted);
    white-space: nowrap;
}

/* Reserve bottom space on any page that renders this bar so footers
   don't get covered. :has() is widely supported in modern admin.  */
body:has(.cds-floating-save) #wpbody-content { padding-bottom: 96px; }

/* Mobile — span full width but stay floating, swap to rounded card */
@media (max-width: 782px) {
    .cds-floating-save {
        bottom: var(--cds-space-3);
        inset-inline-end: var(--cds-space-3);
        inset-inline-start: var(--cds-space-3);
        border-radius: var(--cds-radius-lg);
        justify-content: space-between;
    }
    .cds-floating-save > button,
    .cds-floating-save > a,
    .cds-floating-save .cds-btn,
    .cds-floating-save .button-primary { flex: 1; }
    .cds-floating-save__hint { display: none; }
    body:has(.cds-floating-save) #wpbody-content { padding-bottom: 80px; }
}
