/* ═══════════════════════════════════════════════════════════════════
   Reprotech.UI.Blazor — Design System
   Ported from the Campaign / Reprotech design reference.
   Namespaced (rt-*) so it never restyles a host app's existing markup.
   Host must also ship Bootstrap Icons for <i class="bi ..."> glyphs.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────────────────────
   The --rt-* tokens are NOT defined here anymore. They are generated from
   the Reprotech UI design system's single source of truth (design-tokens.json)
   into rt-tokens.css, which the host must link BEFORE this file:

       <link rel="stylesheet" href="_content/Reprotech.UI.Blazor/css/rt-tokens.css" />
       <link rel="stylesheet" href="_content/Reprotech.UI.Blazor/css/rt-theme.css" />

   This is what keeps the Cryo-Logix portal from drifting from the brand — the
   same way Web (React) and Android (Compose) consume that source of truth.
   To change a colour, edit the DS tokens and regenerate; never hand-edit here.
   ──────────────────────────────────────────────────────────────────── */

/* ── Buttons ────────────────────────────────────────────────────── */
.rt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 999px; /* pill shape */
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.5;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.rt-btn:disabled,
.rt-btn[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Primary — solid dark plum, orchid highlight on hover */
.rt-btn-primary {
    background-color: var(--rt-plum);
    border-color: var(--rt-plum);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(30, 7, 34, 0.35);
}

    .rt-btn-primary:hover:not(:disabled) {
        background-color: var(--rt-orchid);
        border-color: var(--rt-orchid);
        color: var(--rt-plum);
        box-shadow: 0 4px 10px rgba(214, 140, 229, 0.45);
    }

/* Outline — transparent, purple border */
.rt-btn-outline {
    background-color: transparent;
    border-color: var(--rt-brand-purple);
    color: var(--rt-brand-purple);
}

    .rt-btn-outline:hover:not(:disabled) {
        background-color: var(--rt-brand-purple-light);
        border-color: var(--rt-brand-purple);
        color: var(--rt-brand-purple);
    }

/* Danger — destructive actions */
.rt-btn-danger {
    background-color: var(--rt-danger);
    border-color: var(--rt-danger);
    color: #FFFFFF;
}

    .rt-btn-danger:hover:not(:disabled) {
        background-color: var(--rt-danger-hover);
        border-color: var(--rt-danger-hover);
        color: #FFFFFF;
    }

/* Secondary — quiet neutral action sitting next to a primary */
.rt-btn-secondary {
    background-color: var(--rt-surface-tertiary);
    border-color: var(--rt-border-default);
    color: var(--rt-text-primary);
}

    .rt-btn-secondary:hover:not(:disabled) {
        background-color: var(--rt-border-default);
        border-color: var(--rt-border-hover);
    }

/* Success / Info / Light — status-coloured actions */
.rt-btn-success {
    background-color: var(--rt-success);
    border-color: var(--rt-success);
    color: #FFFFFF;
}

    .rt-btn-success:hover:not(:disabled) {
        background-color: var(--rt-success-light);
        border-color: var(--rt-success-light);
    }

.rt-btn-info {
    background-color: var(--rt-info);
    border-color: var(--rt-info);
    color: #FFFFFF;
}

    .rt-btn-info:hover:not(:disabled) {
        background-color: var(--rt-accent-800-tint);
        border-color: var(--rt-accent-800-tint);
    }

.rt-btn-light {
    background-color: var(--rt-surface-secondary);
    border-color: var(--rt-border-default);
    color: var(--rt-text-primary);
}

    .rt-btn-light:hover:not(:disabled) {
        background-color: var(--rt-surface-subtle);
    }

/* Link — inline text action, no button chrome */
.rt-btn-link {
    background-color: transparent;
    border-color: transparent;
    color: var(--rt-text-link);
    padding-left: 0;
    padding-right: 0;
    text-decoration: underline;
    box-shadow: none;
}

    .rt-btn-link:hover:not(:disabled) {
        color: var(--rt-accent-800-tint);
    }

/* Outline variants — one rule per colour, driven by the Outline parameter.
   currentColor keeps the border, glyph and label in step so each only names
   its colour once. */
.rt-btn-outline-primary,
.rt-btn-outline-secondary,
.rt-btn-outline-danger,
.rt-btn-outline-success,
.rt-btn-outline-info,
.rt-btn-outline-light {
    background-color: transparent;
    border-color: currentColor;
}

.rt-btn-outline-primary   { color: var(--rt-plum); }
.rt-btn-outline-secondary { color: var(--rt-text-secondary); }
.rt-btn-outline-danger    { color: var(--rt-danger); }
.rt-btn-outline-success   { color: var(--rt-success); }
.rt-btn-outline-info      { color: var(--rt-info); }
.rt-btn-outline-light     { color: var(--rt-text-secondary); }

.rt-btn-outline-primary:hover:not(:disabled)   { background-color: var(--rt-brand-purple-light); }
.rt-btn-outline-secondary:hover:not(:disabled) { background-color: var(--rt-surface-subtle); }
.rt-btn-outline-danger:hover:not(:disabled)    { background-color: var(--rt-error-bg); }
.rt-btn-outline-success:hover:not(:disabled)   { background-color: var(--rt-success-bg); }
.rt-btn-outline-info:hover:not(:disabled)      { background-color: var(--rt-info-bg); }
.rt-btn-outline-light:hover:not(:disabled)     { background-color: var(--rt-surface-subtle); }

/* Size modifiers */
.rt-btn-sm {
    padding: 0.2rem 0.75rem;
    font-size: 0.8rem;
}

.rt-btn-lg {
    padding: 0.5rem 1.35rem;
    font-size: 1rem;
}

/* Anchors rendered by NavigateUrl are not :disabled-able, so keep them from
   inheriting the host's link underline on the non-Link variants. */
a.rt-btn:not(.rt-btn-link) {
    text-decoration: none;
}

/* ── rt-input-field — Floating label input wrapper ─────────────────
   Label sits on the top-left border edge. Default border warm amber,
   focus border brand purple. No Bootstrap dependency.               */
.rt-input-field {
    position: relative;
    padding-top: 8px;
    margin-bottom: 14px;
}

    .rt-input-field > label {
        position: absolute;
        top: 8px;
        left: 12px;
        transform: translateY(-50%);
        background: #FFFFFF;
        padding: 0 4px;
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--rt-brand-purple);
        z-index: 2;
        white-space: nowrap;
        pointer-events: none;
        line-height: 1;
    }

    .rt-input-field > input,
    .rt-input-field > select,
    .rt-input-field > textarea {
        display: block;
        width: 100%;
        border: 1.5px solid var(--rt-field-border);
        border-radius: 8px;
        padding: 9px 14px;
        font-size: 0.875rem;
        color: #374151;
        background: #FFFFFF;
        outline: none;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
        box-sizing: border-box;
        font-family: inherit;
        line-height: 1.5;
        margin: 0;
    }

    .rt-input-field > input:focus,
    .rt-input-field > select:focus,
    .rt-input-field > textarea:focus {
        border-color: var(--rt-brand-purple);
        box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.12);
    }

    .rt-input-field > input::placeholder,
    .rt-input-field > textarea::placeholder {
        color: #9CA3AF;
        font-style: italic;
    }

    .rt-input-field > input[readonly] {
        background: #F9FAFB;
        color: #6B7280;
        border-color: #E5E7EB;
        cursor: default;
    }

    .rt-input-field > input:disabled,
    .rt-input-field > select:disabled,
    .rt-input-field > textarea:disabled {
        background: #F9FAFB;
        color: #9CA3AF;
        border-color: #E5E7EB;
        opacity: 1;
        cursor: not-allowed;
    }

.rt-input-field.mb-0 {
    margin-bottom: 0;
}

/* ── rt-card ───────────────────────────────────────────────────── */
.rt-card {
    background: var(--rt-content-bg);
    border: 1px solid var(--rt-divider-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.rt-card-header {
    background-color: var(--rt-page-header-bg);
    border-bottom: 1px solid var(--rt-divider-color);
    padding: 12px 16px;
}

.rt-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1F2937;
}

.rt-card-body {
    padding: 16px;
}

/* ── Shared ─────────────────────────────────────────────────────── */
.rt-disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ── rt-check — checkbox & switch ──────────────────────────────── */
.rt-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    user-select: none;
}

.rt-check.rt-disabled {
    cursor: not-allowed;
}

.rt-check .rt-check-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.rt-check .rt-check-box {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--rt-field-border);
    border-radius: 4px;
    background: #FFFFFF;
    position: relative;
    flex: 0 0 auto;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rt-check .rt-check-input:checked + .rt-check-box {
    background: var(--rt-brand-purple);
    border-color: var(--rt-brand-purple);
}

.rt-check .rt-check-input:checked + .rt-check-box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #FFFFFF;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.rt-check .rt-check-input:focus-visible + .rt-check-box {
    box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.18);
}

/* Switch variant */
.rt-check-switch .rt-check-box {
    width: 36px;
    height: 20px;
    border-radius: 999px;
}

.rt-check-switch .rt-check-box::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 1px;
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: #FFFFFF;
    transform: none;
    transition: left 0.15s ease;
}

.rt-check-switch .rt-check-input:checked + .rt-check-box::after {
    left: 18px;
    border: none;
    width: 14px;
    height: 14px;
    transform: none;
}

/* ── rt-radio-group / rt-checkbox-group ───────────────────────── */
.rt-radio-group,
.rt-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rt-radio-group.rt-radio-horizontal,
.rt-checkbox-group.rt-group-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
}

.rt-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
}

.rt-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.rt-radio .rt-radio-mark {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--rt-field-border);
    border-radius: 50%;
    background: #FFFFFF;
    position: relative;
    flex: 0 0 auto;
}

.rt-radio input:checked + .rt-radio-mark {
    border-color: var(--rt-brand-purple);
}

.rt-radio input:checked + .rt-radio-mark::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rt-brand-purple);
}

/* ── rt-spin ───────────────────────────────────────────────────── */
.rt-spin {
    position: relative;
    display: flex;
    align-items: stretch;
}

.rt-spin .rt-spin-input {
    display: block;
    width: 100%;
    border: 1.5px solid var(--rt-field-border);
    border-radius: 8px;
    padding: 9px 34px 9px 14px;
    font-size: 0.875rem;
    color: #374151;
    background: #FFFFFF;
    outline: none;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.rt-spin .rt-spin-input::-webkit-outer-spin-button,
.rt-spin .rt-spin-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.rt-spin .rt-spin-input:focus {
    border-color: var(--rt-brand-purple);
    box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.12);
}

.rt-spin .rt-spin-buttons {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.rt-spin .rt-spin-buttons button {
    border: none;
    background: transparent;
    color: #6B7280;
    font-size: 0.55rem;
    line-height: 1;
    padding: 1px 3px;
    cursor: pointer;
}

.rt-spin .rt-spin-buttons button:hover:not(:disabled) {
    color: var(--rt-brand-purple);
}

/* ── rt-combo ──────────────────────────────────────────────────── */
.rt-combo {
    position: relative;
}

.rt-combo .rt-combo-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 1.5px solid var(--rt-field-border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.875rem;
    background: #FFFFFF;
    color: #374151;
    cursor: pointer;
    text-align: left;
}

.rt-combo.rt-combo-open .rt-combo-display,
.rt-combo .rt-combo-display:focus {
    border-color: var(--rt-brand-purple);
    box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.12);
    outline: none;
}

.rt-combo .rt-combo-placeholder {
    color: #9CA3AF;
    font-style: italic;
}

.rt-combo .rt-combo-caret {
    font-style: normal;
    color: #6B7280;
    margin-left: 8px;
}

.rt-combo .rt-combo-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.rt-combo .rt-combo-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 41;
    background: #FFFFFF;
    border: 1px solid var(--rt-divider-color);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

/* The editor itself. Borderless because .rt-combo-display already draws the
   field; this only supplies the text box behaviour. */
.rt-combo .rt-combo-input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    outline: none;
}

    .rt-combo .rt-combo-input::placeholder {
        color: #9CA3AF;
        font-style: italic;
    }

/* While open, lift the field above the click-catching backdrop so clicking
   into the text box does not read as a click-outside and close the menu. */
.rt-combo.rt-combo-open .rt-combo-display {
    position: relative;
    z-index: 42;
}

.rt-combo .rt-combo-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
}

.rt-combo .rt-combo-display {
    min-height: 40px;
}

.rt-combo .rt-combo-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.rt-combo .rt-combo-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 8px;
    background: var(--rt-brand-purple-subtle);
    color: var(--rt-brand-purple);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.rt-combo .rt-combo-tag-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--rt-brand-purple);
}

.rt-combo .rt-combo-tag-x:hover {
    background: rgba(123, 75, 191, 0.18);
}

.rt-combo .rt-combo-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
}

.rt-combo .rt-combo-option:hover {
    background: var(--rt-brand-purple-light);
}

.rt-combo .rt-combo-selected {
    background: var(--rt-brand-purple-subtle);
    font-weight: 600;
    color: var(--rt-brand-purple);
}

/* Keyboard highlight. Listed after :hover so arrow keys win over a stale
   pointer position. */
.rt-combo .rt-combo-active {
    background: var(--rt-brand-purple-light);
    box-shadow: inset 2px 0 0 var(--rt-brand-purple);
}

.rt-combo .rt-combo-empty {
    padding: 8px 14px;
    font-size: 0.85rem;
    color: #9CA3AF;
    font-style: italic;
}

/* ── rt-listbox ────────────────────────────────────────────────── */
.rt-listbox {
    border: 1.5px solid var(--rt-field-border);
    border-radius: 8px;
    background: #FFFFFF;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
}

.rt-listbox .rt-listbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
}

.rt-listbox .rt-listbox-option:hover {
    background: var(--rt-brand-purple-light);
}

.rt-choice-check {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 1.5px solid var(--rt-field-border);
    border-radius: 4px;
    background: #FFFFFF;
    position: relative;
}

.rt-choice-check.rt-checked {
    background: var(--rt-brand-purple);
    border-color: var(--rt-brand-purple);
}

.rt-choice-check.rt-checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #FFFFFF;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.rt-listbox .rt-listbox-text {
    min-width: 0;
}

.rt-listbox .rt-listbox-selected {
    background: var(--rt-brand-purple-subtle);
    font-weight: 600;
    color: var(--rt-brand-purple);
}

/* ── rt-daterange ──────────────────────────────────────────────── */
.rt-daterange {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rt-daterange .rt-date-input {
    border: 1.5px solid var(--rt-field-border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.875rem;
    color: #374151;
    background: #FFFFFF;
    outline: none;
}

.rt-daterange .rt-date-input:focus {
    border-color: var(--rt-brand-purple);
    box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.12);
}

.rt-daterange .rt-daterange-sep {
    color: #6B7280;
}

/* ── rt-form-layout — 12-column responsive form grid ───────────── */
.rt-form-layout {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 4px 16px;
    align-items: start;
}

.rt-form-item {
    display: flex;
    min-width: 0;
    margin-bottom: 10px;
}

.rt-form-item.rt-caption-vertical {
    flex-direction: column;
    gap: 4px;
}

.rt-form-item.rt-caption-horizontal {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.rt-form-item-caption {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4B5563;
}

.rt-caption-horizontal > .rt-form-item-caption {
    flex: 0 0 auto;
    text-align: right;
    min-width: 120px;
}

.rt-form-item-editor {
    min-width: 0;
    flex: 1 1 auto;
}

/* Group — captioned fieldset that itself spans columns */
.rt-form-group {
    min-width: 0;
    border: 1px solid var(--rt-divider-color);
    border-radius: 10px;
    background: var(--rt-content-bg);
    padding: 0 0 8px;
    margin-bottom: 12px;
}

.rt-form-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--rt-page-header-bg);
    border-bottom: 1px solid var(--rt-divider-color);
    border-radius: 10px 10px 0 0;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.rt-form-group-caption {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1F2937;
}

.rt-form-group > .rt-form-layout {
    padding: 0 14px;
}

/* Large-breakpoint column overrides */
@media (min-width: 992px) {
    .rt-col-lg-1 { grid-column: span 1; }
    .rt-col-lg-2 { grid-column: span 2; }
    .rt-col-lg-3 { grid-column: span 3; }
    .rt-col-lg-4 { grid-column: span 4; }
    .rt-col-lg-5 { grid-column: span 5; }
    .rt-col-lg-6 { grid-column: span 6; }
    .rt-col-lg-7 { grid-column: span 7; }
    .rt-col-lg-8 { grid-column: span 8; }
    .rt-col-lg-9 { grid-column: span 9; }
    .rt-col-lg-10 { grid-column: span 10; }
    .rt-col-lg-11 { grid-column: span 11; }
    .rt-col-lg-12 { grid-column: span 12; }
}

/* Collapse the grid to a single column on small screens */
@media (max-width: 767px) {
    .rt-form-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .rt-form-item,
    .rt-form-group,
    .rt-form-tabs {
        grid-column: span 1 !important;
    }
}

/* ── rt-tab-strip — form layout tab pages ──────────────────────── */
.rt-form-tabs {
    min-width: 0;
    margin-bottom: 12px;
}

.rt-tab-strip {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--rt-divider-color);
}

.rt-tab {
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6B7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.rt-tab:hover {
    color: var(--rt-brand-purple);
}

.rt-tab.rt-tab-active {
    color: var(--rt-brand-purple);
    border-bottom-color: var(--rt-brand-purple);
    font-weight: 600;
}

.rt-tab-content {
    padding-top: 14px;
}

/* ── rt-grid-layout — CSS grid areas ───────────────────────────── */
.rt-grid-layout {
    gap: 8px;
}

.rt-grid-layout-item {
    min-width: 0;
}

/* ── rt-tabs (standalone) ──────────────────────────────────────── */
.rt-tabs .rt-tab i {
    margin-right: 6px;
}

.rt-tab-panel {
    padding-top: 4px;
}

/* ── rt-accordion ──────────────────────────────────────────────── */
.rt-accordion {
    border: 1px solid var(--rt-divider-color);
    border-radius: 10px;
    overflow: hidden;
}

.rt-accordion-item + .rt-accordion-item {
    border-top: 1px solid var(--rt-divider-color);
}

/* Header actions sit alongside the toggle, not inside it — the toggle is a
   button and cannot legally contain one. */
.rt-accordion-header-row {
    display: flex;
    align-items: stretch;
    background: var(--rt-page-header-bg);
}

.rt-accordion-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    background: var(--rt-page-header-bg);
    align-self: stretch;
}

.rt-accordion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    border: none;
    background: var(--rt-page-header-bg);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1F2937;
    cursor: pointer;
    text-align: left;
}

/* Fills the rest of the bar so the header stays clickable end to end. */
.rt-accordion-header-rest {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    background: var(--rt-page-header-bg);
    padding: 12px 16px;
    cursor: pointer;
}

.rt-accordion-header-row:hover .rt-accordion-header,
.rt-accordion-header-row:hover .rt-accordion-header-actions,
.rt-accordion-header-row:hover .rt-accordion-header-rest {
    background: var(--rt-brand-purple-light);
}

.rt-accordion-text {
    flex: 0 1 auto;
}

.rt-accordion-chevron {
    font-style: normal;
    color: #6B7280;
    transition: transform 0.15s ease;
}

.rt-accordion-chevron.rt-expanded {
    transform: rotate(180deg);
}

.rt-accordion-body {
    padding: 14px 16px;
    background: var(--rt-content-bg);
}

/* ── rt-toolbar ────────────────────────────────────────────────── */
.rt-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--rt-page-header-bg);
    border: 1px solid var(--rt-divider-color);
    border-radius: 8px;
}

.rt-toolbar-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
}

.rt-toolbar-item:hover:not(:disabled) {
    background: var(--rt-brand-purple-light);
    color: var(--rt-brand-purple);
}

.rt-toolbar-item.rt-toolbar-right {
    margin-left: auto;
}

.rt-toolbar-sep {
    width: 1px;
    align-self: stretch;
    background: var(--rt-divider-color);
    margin: 0 4px;
}

/* ── rt-menu ───────────────────────────────────────────────────── */
.rt-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--rt-content-bg);
    border: 1px solid var(--rt-divider-color);
    border-radius: 8px;
}

.rt-menu-item {
    position: relative;
}

.rt-menu-item.rt-menu-group {
    border-left: 1px solid var(--rt-divider-color);
}

.rt-menu-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.rt-menu-link:hover {
    background: var(--rt-brand-purple-light);
    color: var(--rt-brand-purple);
}

.rt-menu-caret {
    font-style: normal;
    font-size: 0.7rem;
    color: #6B7280;
}

.rt-submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    min-width: 180px;
    background: var(--rt-content-bg);
    border: 1px solid var(--rt-divider-color);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.rt-menu-item:hover > .rt-submenu {
    display: block;
}

.rt-submenu .rt-menu-link {
    width: 100%;
}

/* ── rt-treeview ───────────────────────────────────────────────── */
.rt-treeview {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
}

.rt-treeview .rt-treeview {
    padding-left: 18px;
}

.rt-tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #374151;
}

.rt-tree-row:hover {
    background: var(--rt-brand-purple-light);
}

.rt-tree-toggle {
    font-style: normal;
    color: #6B7280;
    width: 12px;
    display: inline-block;
    transition: transform 0.15s ease;
}

.rt-tree-toggle.rt-expanded {
    transform: rotate(90deg);
}

.rt-tree-toggle-spacer {
    width: 12px;
    display: inline-block;
}

.rt-tree-icon {
    color: var(--rt-brand-purple);
}

.rt-tree-text {
    color: inherit;
    text-decoration: none;
}

a.rt-tree-text:hover {
    text-decoration: underline;
}

.rt-tree-selected {
    background: var(--rt-brand-purple-subtle);
    color: var(--rt-brand-purple-hover);
    font-weight: 500;
}

/* ── rt-treeview, nav appearance (dark chrome) ─────────────────── */
.rt-treeview-nav {
    background: var(--rt-surface-sidebar);
    padding: 8px;
    font-size: 0.9375rem;
}

.rt-treeview-nav .rt-treeview {
    padding-left: 28px;
}

.rt-treeview-nav .rt-tree-row {
    color: color-mix(in srgb, var(--rt-text-inverse) 75%, transparent);
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    font-weight: 500;
}

.rt-treeview-nav .rt-tree-row:hover {
    background: color-mix(in srgb, var(--rt-text-inverse) 8%, transparent);
    color: var(--rt-text-inverse);
}

.rt-treeview-nav .rt-tree-selected,
.rt-treeview-nav .rt-tree-selected:hover {
    background: color-mix(in srgb, var(--rt-text-inverse) 12%, transparent);
    color: var(--rt-text-inverse);
    font-weight: 600;
}

.rt-treeview-nav .rt-tree-icon {
    width: 20px;
    font-size: 1.125rem;
    text-align: center;
    color: var(--rt-brand-muted);
}

.rt-treeview-nav .rt-tree-selected .rt-tree-icon {
    color: var(--rt-text-inverse);
}

.rt-treeview-nav .rt-tree-toggle {
    color: color-mix(in srgb, var(--rt-text-inverse) 50%, transparent);
}

.rt-treeview-nav .rt-tree-toggle-spacer {
    display: none;
}

/* ── rt-sidebar ───────────────────────────────────────────────── */
.rt-sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    flex: 0 0 260px;
    height: 100%;
    background: var(--rt-surface-sidebar);
    color: var(--rt-text-inverse);
    font-size: 0.875rem;
}

.rt-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 14px;
}

.rt-sidebar-brand-icon {
    font-size: 1.5rem;
    color: var(--rt-text-inverse);
}

.rt-sidebar-brand-text {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rt-sidebar-app {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 20px);
    margin: 0 10px 10px;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

button.rt-sidebar-app {
    cursor: pointer;
}

button.rt-sidebar-app:hover {
    background: color-mix(in srgb, var(--rt-text-inverse) 8%, transparent);
}

.rt-sidebar-app-icon {
    font-size: 1.25rem;
    color: var(--rt-brand-muted);
}

.rt-sidebar-app-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rt-sidebar-app-name {
    font-size: 1rem;
    font-weight: 600;
}

.rt-sidebar-app-desc {
    font-size: 0.75rem;
    color: color-mix(in srgb, var(--rt-text-inverse) 60%, transparent);
}

.rt-sidebar-app-caret {
    font-style: normal;
    color: color-mix(in srgb, var(--rt-text-inverse) 60%, transparent);
}

.rt-sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 10px;
}

.rt-sidebar-nav .rt-treeview-nav {
    background: transparent;
    padding: 0;
}

.rt-sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid color-mix(in srgb, var(--rt-text-inverse) 12%, transparent);
}

.rt-sidebar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--rt-brand-muted);
    color: var(--rt-plum);
    font-size: 0.8125rem;
    font-weight: 600;
}

.rt-sidebar-user {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rt-sidebar-user-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-sidebar-user-role {
    font-size: 0.75rem;
    color: color-mix(in srgb, var(--rt-text-inverse) 60%, transparent);
}

.rt-sidebar-user-account {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: color-mix(in srgb, var(--rt-text-inverse) 45%, transparent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-sidebar-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.rt-sidebar-signout {
    padding: 0;
    border: none;
    background: transparent;
    color: color-mix(in srgb, var(--rt-text-inverse) 70%, transparent);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.rt-sidebar-signout:hover {
    color: var(--rt-text-inverse);
}

.rt-sidebar-version {
    font-size: 0.6875rem;
    color: color-mix(in srgb, var(--rt-text-inverse) 45%, transparent);
}

/* ── rt-popup / rt-window ─────────────────────────────────────── */
.rt-popup-backdrop,
.rt-window-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.rt-popup,
.rt-window {
    background: var(--rt-content-bg);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.30);
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 320px;
}

.rt-popup-header,
.rt-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--rt-page-header-bg);
    border-bottom: 1px solid var(--rt-divider-color);
}

.rt-popup-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1F2937;
}

.rt-popup-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: #6B7280;
    cursor: pointer;
    padding: 0 4px;
}

.rt-popup-close:hover {
    color: var(--rt-danger);
}

.rt-popup-body,
.rt-window-body {
    padding: 18px;
    overflow-y: auto;
}

.rt-window-resize {
    resize: both;
    min-height: 120px;
}

.rt-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--rt-divider-color);
    background: var(--rt-page-header-bg);
}

/* ── rt-spinner (shared) ───────────────────────────────────────── */
.rt-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--rt-brand-purple-subtle);
    border-top-color: var(--rt-brand-purple);
    border-radius: 50%;
    animation: rt-spin 0.7s linear infinite;
}

.rt-spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

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

/* ── rt-loading-panel ──────────────────────────────────────────── */
.rt-loading-panel {
    position: relative;
    min-height: 60px;
}

.rt-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.72);
    z-index: 10;
}

.rt-loading-blocked {
    cursor: progress;
}

.rt-loading-text {
    font-size: 0.85rem;
    color: var(--rt-brand-purple);
    font-weight: 600;
}

/* ── rt-wait ───────────────────────────────────────────────────── */
.rt-wait {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--rt-brand-purple);
    font-size: 0.85rem;
}

/* ── rt-toast ──────────────────────────────────────────────────── */
.rt-toast-region {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.rt-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--rt-content-bg);
    border-left: 4px solid var(--rt-brand-purple);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}

.rt-toast-info { border-left-color: var(--rt-badge-blue-text); }
.rt-toast-success { border-left-color: var(--rt-badge-green-text); }
.rt-toast-warning { border-left-color: var(--rt-badge-orange-text); }
.rt-toast-error { border-left-color: var(--rt-danger); }

.rt-toast-content {
    flex: 1 1 auto;
    min-width: 0;
}

.rt-toast-title {
    font-weight: 600;
    color: #1F2937;
    font-size: 0.9rem;
}

.rt-toast-text {
    font-size: 0.85rem;
    color: #4B5563;
}

.rt-toast-close {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    line-height: 1;
    color: #9CA3AF;
    cursor: pointer;
}

.rt-toast-close:hover {
    color: #374151;
}

/* ── rt-grid ───────────────────────────────────────────────────── */
.rt-grid {
    border: 1px solid var(--rt-divider-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--rt-content-bg);
}

.rt-grid-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    padding: 10px 12px;
    border-bottom: 1px solid var(--rt-divider-color);
    background: var(--rt-page-header-bg);
}

/* Takes the slack so the search box stays pinned right. */
.rt-grid-toolbar-content {
    flex: 1;
    min-width: 0;
}

.rt-grid-search {
    border: 1.5px solid var(--rt-field-border);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    outline: none;
    min-width: 220px;
    /* Declared, not left to the UA default, which is opaque white and punches
       a bright box through the toolbar band on a tinted canvas. */
    background: transparent;
}

.rt-grid-search:focus {
    border-color: var(--rt-brand-purple);
    box-shadow: 0 0 0 3px rgba(123, 75, 191, 0.12);
}

.rt-grid-scroll {
    overflow: auto;
}

.rt-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

/* Sticky headers so they stay put when the body scrolls under MaxBodyHeight. */
.rt-grid-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ── rt-grid, filter row ──────────────────────────────────────── */
.rt-grid-table thead .rt-grid-filter-row th {
    top: 41px;
    padding: 6px 8px;
    background: var(--rt-surface-primary);
}

.rt-grid-filter {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 4px 8px;
    border: 1px solid var(--rt-field-border);
    border-radius: 6px;
    /* Transparent so the filter-row band shows through, matching .rt-grid-search
       above. On the default white card this still reads white; on a tinted
       canvas a hardcoded #FFF punched a bright box through the header band. */
    background: transparent;
    font: inherit;
    font-size: 0.8rem;
}

    .rt-grid-filter:focus {
        border-color: var(--rt-brand-purple);
        outline: none;
        box-shadow: 0 0 0 2px rgba(123, 75, 191, 0.12);
    }

/* ── rt-grid, hover highlight ─────────────────────────────────── */
.rt-grid-hover .rt-grid-table tbody tr:hover {
    background: var(--rt-brand-purple-light);
}

/* ── rt-grid, column resizing ─────────────────────────────────── */
/* No position rule on th here on purpose: the sticky header above already
   establishes the containing block the resizer anchors to, and re-declaring
   position:relative would beat it on specificity and unstick the header. */
.rt-grid-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
}

    .rt-grid-resizer:hover {
        background: var(--rt-brand-purple);
        opacity: 0.35;
    }

.rt-grid-table thead th {
    background: var(--rt-table-header-bg);
    color: #1F2937;
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--rt-divider-color);
    white-space: nowrap;
}

.rt-grid-table thead .rt-grid-band {
    text-align: center;
    border-left: 1px solid var(--rt-divider-color);
    border-right: 1px solid var(--rt-divider-color);
}

.rt-grid-th {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rt-grid-th.rt-sortable {
    cursor: pointer;
}

.rt-grid-th.rt-sortable:hover {
    color: var(--rt-brand-purple);
}

.rt-sort-arrow {
    font-size: 0.7rem;
    color: var(--rt-brand-purple);
}

.rt-grid-table tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--rt-divider-color);
    color: #374151;
}

.rt-grid-table tbody tr:last-child td {
    border-bottom: none;
}

.rt-grid-table tbody tr:hover {
    background: var(--rt-brand-purple-light);
}

.rt-grid-row-selected {
    background: var(--rt-brand-purple-subtle) !important;
}

.rt-grid-row-clickable {
    cursor: pointer;
}

.rt-align-left { text-align: left; }
.rt-align-center { text-align: center; }
.rt-align-right { text-align: right; }

.rt-grid-empty {
    text-align: center;
    color: #9CA3AF;
    font-style: italic;
    padding: 24px 14px !important;
}

/* ── Row density ── */
.rt-grid-sm .rt-grid-table th,
.rt-grid-sm .rt-grid-table td {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.rt-grid-lg .rt-grid-table th,
.rt-grid-lg .rt-grid-table td {
    padding: 12px 16px;
}

/* ── Detail rows ── */
.rt-grid-expander-col {
    width: 36px;
    text-align: center;
}

.rt-grid-expander {
    border: 0;
    background: transparent;
    color: var(--rt-text-tertiary);
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
}

    .rt-grid-expander:hover {
        color: var(--rt-brand-purple);
    }

.rt-grid-detail-row > td {
    background: var(--rt-surface-subtle);
    padding: 12px 16px;
}

.rt-grid-cmd-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rt-grid-cmd {
    border: 1px solid var(--rt-brand-purple);
    background: transparent;
    color: var(--rt-brand-purple);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    margin-right: 4px;
}

.rt-grid-cmd:hover {
    background: var(--rt-brand-purple-light);
}

.rt-grid-cmd-new {
    border-radius: 999px;
}

.rt-grid-cmd-delete {
    border-color: var(--rt-danger);
    color: var(--rt-danger);
}

.rt-grid-cmd-delete:hover {
    background: var(--rt-badge-red-bg);
}

.rt-grid-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--rt-divider-color);
    background: var(--rt-page-header-bg);
    font-size: 0.85rem;
    color: #4B5563;
}

.rt-grid-pager button {
    border: 1px solid var(--rt-divider-color);
    background: var(--rt-content-bg);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: #374151;
}

.rt-grid-pager button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rt-grid-pager button:hover:not(:disabled) {
    border-color: var(--rt-brand-purple);
    color: var(--rt-brand-purple);
}

.rt-status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--rt-badge-purple-bg);
    color: var(--rt-badge-purple-text);
}

/* ── rt-upload ─────────────────────────────────────────────────── */
.rt-upload {
    border: 1.5px dashed var(--rt-field-border);
    border-radius: 10px;
    padding: 16px;
    background: var(--rt-content-bg);
}

.rt-upload-native {
    display: none;
}

.rt-upload-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.rt-upload-btn {
    display: inline-flex;
    cursor: pointer;
}

.rt-upload-hint {
    font-size: 0.8rem;
    color: #9CA3AF;
}

.rt-upload-error {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--rt-danger);
}

.rt-upload-files {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rt-upload-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--rt-page-header-bg);
    border-radius: 6px;
    font-size: 0.85rem;
    color: #374151;
}

.rt-upload-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-upload-size {
    color: #6B7280;
    font-size: 0.78rem;
}
