/* App-specific styles — app.brrain.io */

/* ===== App Shell ===== */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== App Header ===== */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.app-header__left,
.app-header__right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.app-header__logo-text {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.app-header__tenants {
    display: flex;
    gap: var(--space-xs);
    margin-right: var(--space-sm);
}
.app-header__tenant-link {
    padding: 6px 12px;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.app-header__tenant-link:hover {
    color: var(--color-accent-cyan);
    border-color: var(--color-accent-cyan);
}
@media (max-width: 720px) {
    .app-header__tenants { display: none; }
}

/* Mobile drawer: the hamburger on the apex top-nav is repurposed below
 * 768px to also slide the app sidebar + the subsystem-header secondary
 * links in alongside the apex nav. One tap, one drawer — no sub-menu
 * hunting on narrow viewports. */
@media (max-width: 767px) {
    .subsystem-header__links { display: none; }
    .subsystem-header__links.is-open {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 12px 16px;
        background: var(--color-surface-1);
        border-bottom: 1px solid var(--color-border);
    }
    .subsystem-header__links.is-open .subsystem-header__link {
        padding: 8px 10px;
        border-radius: 6px;
    }
    .app-sidebar.is-open {
        padding: 16px;
    }
    body.app-menu-open { overflow: hidden; }
}

.app-header__notifications {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.app-header__notifications:hover {
    border-color: var(--color-surface-5);
}

.app-header__user {
    position: relative;
}

.app-header__user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast);
}

.app-header__user-btn:hover {
    border-color: var(--color-surface-5);
}

.app-header__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--color-accent-cyan-muted);
    color: var(--color-accent-cyan);
    font-size: var(--text-xs);
    font-weight: 600;
}

.app-header__dropdown {
    position: absolute;
    top: calc(100% + var(--space-xs));
    right: 0;
    min-width: 180px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    z-index: var(--z-dropdown);
}

.app-header__dropdown[hidden] {
    display: none;
}

.app-header__dropdown-item {
    display: block;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.app-header__dropdown-item:hover {
    background: var(--color-surface-2);
    color: var(--color-text-primary);
}

.app-header__dropdown-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-xs) 0;
}

/* ===== Sidebar toggle (mobile) ===== */

.app-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
}

@media (min-width: 768px) {
    .app-sidebar-toggle {
        display: none;
    }
}

/* ===== App Body ===== */

.app-body {
    display: flex;
    flex: 1;
}

/* ===== App Sidebar ===== */

/* Sticky top matches the combined height of the marketing top nav plus the
   subsystem header above it. Both headers are sticky and stack, so the
   sidebar starts just below the second header. */
.app-sidebar {
    display: none;
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    padding: var(--space-md);
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}

.app-sidebar.is-open {
    display: block;
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    background: var(--color-bg);
    z-index: var(--z-overlay);
}

@media (min-width: 768px) {
    .app-sidebar {
        display: block;
    }

    .app-sidebar.is-open {
        position: sticky;
    }
}

.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-sidebar__divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--space-md) 0 var(--space-sm);
}
.app-sidebar__label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-tertiary);
    padding: 0 var(--space-sm);
    margin-bottom: var(--space-xs);
}
.app-sidebar__ext {
    font-size: 0.8em;
    color: var(--color-text-tertiary);
    margin-left: auto;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-sm);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.app-sidebar__link:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-1);
}

.app-sidebar__link--active {
    color: var(--color-accent-cyan);
    background: var(--color-accent-cyan-muted);
}

.app-sidebar__link svg {
    flex-shrink: 0;
}

/* ===== Sidebar collapsable group (Organizations + sub-tabs) ===== */

.app-sidebar__group > summary {
    list-style: none;
    cursor: pointer;
}
.app-sidebar__group > summary::-webkit-details-marker {
    display: none;
}

.app-sidebar__link--summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: relative;
}

.app-sidebar__link--summary > span {
    flex: 1;
}

.app-sidebar__chevron {
    color: var(--color-text-tertiary);
    transition: transform 150ms ease;
    flex-shrink: 0;
}

.app-sidebar__group[open] > summary .app-sidebar__chevron {
    transform: rotate(90deg);
}

.app-sidebar__group-children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 4px 24px;
    margin-left: 8px;
    border-left: 1px solid var(--color-border);
}

.app-sidebar__sublink {
    display: block;
    padding: 6px 10px;
    font-size: calc(var(--text-sm) - 1px);
    color: var(--color-text-tertiary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.app-sidebar__sublink:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-1);
}

.app-sidebar__sublink--active {
    color: var(--color-accent-cyan);
    background: var(--color-accent-cyan-muted);
}

/* ===== App Main ===== */

.app-main {
    flex: 1;
    min-width: 0;
    /* Top + left padding halved so content sits closer to the second
       header (top) and the sidebar (left). Right/bottom keep the
       original rhythm so the column still breathes. */
    padding: var(--space-md) var(--space-lg) var(--space-lg) var(--space-md);
}

@media (min-width: 768px) {
    .app-main {
        padding: var(--space-md) var(--space-xl) var(--space-lg) var(--space-md);
    }
}

/* ===== Page Header ===== */

.app-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.app-page-header__title {
    font-size: var(--text-2xl);
    font-weight: 700;
}

.app-page-header__subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    width: 100%;
}

/* ===== Section title ===== */

.app-section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
}

/* ===== Stat cards ===== */

.app-dashboard__cards,
.partner-dashboard__cards,
.partner-commissions__summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
    .app-dashboard__cards,
    .partner-dashboard__cards,
    .partner-commissions__summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .app-dashboard__cards,
    .partner-dashboard__cards {
        grid-template-columns: repeat(4, 1fr);
    }
    /* Card-span modifiers — 25/50/75/100 against the 4-col grid. Add new
       dashboard cards by picking the matching width class. */
    .app-stat-card--25 { grid-column: span 1; }
    .app-stat-card--50 { grid-column: span 2; }
    .app-stat-card--75 { grid-column: span 3; }
    .app-stat-card--100 { grid-column: span 4; }
}

/* Extra structure used by cards that host a list (courses in progress,
   badges earned) inside the same app-stat-card chrome. */
.app-stat-card__head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: var(--space-sm);
    gap: var(--space-sm);
}
.app-stat-card__link {
    font-size: var(--text-sm);
    color: var(--color-accent-cyan);
    text-decoration: none;
}
.app-stat-card__link:hover { text-decoration: underline; }
.app-stat-card__list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.app-stat-card__list-link {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-xs) 0;
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    text-decoration: none;
    border-top: 1px solid var(--color-border);
    transition: color var(--transition-fast);
}
.app-stat-card__list li:first-child .app-stat-card__list-link { border-top: none; }
.app-stat-card__list-link:hover { color: var(--color-accent-cyan); }
.app-stat-card__list-action { color: var(--color-text-tertiary); font-size: 12px; }
.app-stat-card__badges {
    list-style: none; padding: 0; margin: 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs);
}
.app-stat-card__badges a {
    display: flex; align-items: center; gap: var(--space-xs);
    padding: var(--space-xs);
    font-size: 12px;
    color: var(--color-text-primary);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}
.app-stat-card__badges a:hover { border-color: var(--color-accent-cyan); }
.app-stat-card__badges img {
    flex-shrink: 0; border-radius: 4px;
    background: rgba(255,255,255,0.03);
}
.app-stat-card__badges span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

    .partner-commissions__summary {
        grid-template-columns: repeat(3, 1fr);
    }
}

.app-stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.app-stat-card__label {
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-tertiary);
}

.app-stat-card__value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text-primary);
}

.app-stat-card__trend {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
}

.app-stat-card__trend--up {
    color: var(--color-success);
}

.app-stat-card__trend--down {
    color: var(--color-error);
}

.app-stat-card__meta {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}

.app-stat-card__bar {
    width: 100%;
    height: 4px;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-xs);
}

.app-stat-card__bar-fill {
    height: 100%;
    background: var(--color-accent-cyan);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ===== Quick actions ===== */

.app-dashboard__actions {
    margin-bottom: var(--space-xl);
}

.app-dashboard__action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* ===== Activity ===== */

.app-dashboard__activity-list {
    display: flex;
    flex-direction: column;
}

.app-activity-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.app-activity-item:last-child {
    border-bottom: none;
}

.app-activity-item__icon {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-text-tertiary);
    flex-shrink: 0;
    margin-top: 6px;
}

.app-activity-item__icon--create { background: var(--color-success); }
.app-activity-item__icon--update { background: var(--color-accent-cyan); }
.app-activity-item__icon--delete { background: var(--color-error); }

.app-activity-item__text {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.app-activity-item__time {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}

.app-dashboard__empty {
    color: var(--color-text-tertiary);
    font-size: var(--text-sm);
    padding: var(--space-lg) 0;
}

/* ===== Tables ===== */

.app-table-wrap {
    overflow-x: auto;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
}

.app-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-tertiary);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.app-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.app-table tr:hover td {
    background: var(--color-surface-1);
}

.app-table__empty {
    text-align: center;
    color: var(--color-text-tertiary);
    padding: var(--space-xl) var(--space-md);
}

.app-table__link {
    color: var(--color-accent-cyan);
    text-decoration: none;
    font-size: var(--text-sm);
}

.app-table__link:hover {
    text-decoration: underline;
}

.app-table__name {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 500;
    color: var(--color-text-primary);
}

.app-table__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--color-surface-3);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    flex-shrink: 0;
}

.app-table__pagination {
    display: flex;
    justify-content: center;
    padding: var(--space-lg) 0;
}

/* ===== Modal ===== */

.app-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-md);
}

.app-modal-backdrop[hidden] {
    display: none;
}

.app-modal {
    width: 100%;
    max-width: 480px;
    /* Opaque per user feedback — modals across all sites must be 100%
       non-transparent so page content never bleeds through. */
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.app-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.app-modal__title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.app-modal__close {
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    font-size: var(--text-xl);
    cursor: pointer;
    line-height: 1;
}

.app-modal__close:hover {
    color: var(--color-text-primary);
}

.app-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* ===== Billing ===== */

.app-billing__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
    .app-billing__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.app-billing__section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-md);
}

.app-billing__plan-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.app-billing__plan-name {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text-primary);
}

.app-billing__plan-price {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--space-md);
}

.app-billing__plan-period {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
    font-weight: 400;
}

.app-billing__invoice-amount {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.app-billing__invoice-date {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.app-billing__card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--space-md);
}

.app-billing__card-brand {
    font-weight: 500;
    color: var(--color-text-primary);
}

.app-billing__card-last4,
.app-billing__card-expiry {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.app-billing__empty {
    color: var(--color-text-tertiary);
    font-size: var(--text-sm);
}

/* ===== Team ===== */

.app-team__invite-form {
    margin-bottom: var(--space-lg);
}

.app-team__invite-form[hidden] {
    display: none;
}

.app-team__section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.app-team__form-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
}

.app-team__form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.app-team__form-actions {
    display: flex;
    gap: var(--space-sm);
}

.app-team__role-select {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    min-width: 100px;
}

/* ===== API Keys ===== */

.app-api-keys__masked {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    letter-spacing: 0.05em;
}

/* ===== Audit Log ===== */

.app-audit-log__filters {
    margin-bottom: var(--space-lg);
}

.app-audit-log__filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
}

.app-audit-log__filter-form .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.app-audit-log__filter-actions {
    display: flex;
    gap: var(--space-sm);
}

.app-audit-log__details {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════
   API KEYS — scope checkboxes + one-time reveal
   ══════════════════════════════════════════════════ */

.app-api-keys__scope {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-1);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.app-api-keys__scope:hover {
    border-color: var(--color-accent-cyan);
    background: var(--color-surface-2);
}
.app-api-keys__scope input {
    margin-top: 3px;
    accent-color: var(--color-accent-cyan);
}
.app-api-keys__scope strong {
    display: block;
    color: var(--color-text-primary);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    margin-bottom: 2px;
}
.app-api-keys__scope-desc {
    display: block;
    color: var(--color-text-tertiary);
    font-size: 12px;
    line-height: 1.4;
}
.app-api-keys__scope-desc code {
    color: var(--color-text-secondary);
    font-size: 11px;
}

.app-api-keys__reveal {
    margin: var(--space-md) 0 var(--space-lg);
    padding: 14px 18px;
    border: 1px solid var(--color-accent-cyan);
    background: rgba(0,235,255,0.06);
    border-radius: var(--radius-md);
}
.app-api-keys__reveal-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.app-api-keys__reveal-head strong {
    color: var(--color-text-primary);
    font-size: 14px;
}
.app-api-keys__reveal-note {
    font-size: 12px;
    color: var(--color-text-tertiary);
}
.app-api-keys__reveal-body {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.app-api-keys__reveal-value {
    flex: 1;
    min-width: 280px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.45);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    color: var(--color-accent-cyan);
    word-break: break-all;
    line-height: 1.4;
}

.app-api-keys__error {
    margin: 10px 0 0;
    padding: 8px 12px;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 13px;
}

.form-help {
    margin: 2px 0 8px;
    color: var(--color-text-tertiary);
    font-size: 12px;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════
   PLAN TAB
   ══════════════════════════════════════════════════ */
.app-plan__current {
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}
.app-plan__current--empty { opacity: 0.85; }
.app-plan__current-head {
    display: flex; align-items: center; gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.app-plan__badge {
    display: inline-block;
    font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 3px 8px; border-radius: 2px;
    background: rgba(0,235,255,0.12); color: var(--color-accent-cyan);
    border: 1px solid rgba(0,235,255,0.35);
}
.app-plan__badge--muted { background: rgba(255,255,255,0.03); color: var(--color-text-tertiary); border-color: var(--color-border); }
.app-plan__status {
    font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px;
}
.app-plan__status--active { background: rgba(74,222,128,0.12); color: #4ade80; }
.app-plan__status--trialing { background: rgba(0,235,255,0.12); color: var(--color-accent-cyan); }
.app-plan__status--past_due { background: rgba(251,191,36,0.12); color: #fbbf24; }
.app-plan__current-name {
    font-family: var(--font-serif);
    font-size: var(--text-2xl); margin: 0 0 6px;
}
.app-plan__renew { color: var(--color-text-secondary); font-size: 13px; margin: 0 0 var(--space-md); }
.app-plan__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.app-plan__cancel-btn { color: var(--color-text-secondary); }

.app-plan__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}
.app-plan__card {
    padding: var(--space-md) var(--space-md) var(--space-lg);
    display: flex; flex-direction: column;
}
.app-plan__card--current { border-color: var(--color-accent-cyan); background: rgba(0,235,255,0.03); }
.app-plan__card-name {
    font-size: 15px; font-weight: 600; margin: 0 0 6px;
}
.app-plan__card-price {
    font-family: var(--font-serif);
    font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
    margin-bottom: 10px;
}
.app-plan__card-desc {
    font-size: 13px; color: var(--color-text-secondary); line-height: 1.55;
    flex: 1; margin: 0 0 var(--space-md);
}
.app-plan__card-cta { align-self: flex-start; }
.app-plan__footnote {
    font-size: 12px; color: var(--color-text-tertiary); margin: 0;
}

/* ══════════════════════════════════════════════════
   NOTIFICATIONS
   ══════════════════════════════════════════════════ */
.app-notifications__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--space-lg);
}
@media (max-width: 900px) { .app-notifications__layout { grid-template-columns: 1fr; } }

.app-notifications__list { list-style: none; margin: 0; padding: 0; }
.app-notifications__item {
    display: flex; gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-1);
    margin-bottom: 8px;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.app-notifications__item--unread { border-color: rgba(0,235,255,0.30); background: rgba(0,235,255,0.03); }
.app-notifications__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: transparent; margin-top: 8px; flex-shrink: 0;
}
.app-notifications__item--unread .app-notifications__dot { background: var(--color-accent-cyan); }
.app-notifications__body { flex: 1; min-width: 0; }
.app-notifications__row {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.app-notifications__title { color: var(--color-text-primary); font-size: 14px; }
.app-notifications__time { color: var(--color-text-tertiary); font-size: 11px; flex-shrink: 0; }
.app-notifications__text { margin: 4px 0 6px; color: var(--color-text-secondary); font-size: 13px; line-height: 1.5; }
.app-notifications__actions { display: flex; gap: 12px; font-size: 12px; margin-top: 4px; }
.app-notifications__link {
    background: none; border: none; padding: 0; font: inherit; cursor: pointer;
    color: var(--color-accent-cyan); text-decoration: none;
}
.app-notifications__link:hover { text-decoration: underline; }
.app-notifications__mark {
    background: none; border: none; padding: 0;
    color: var(--color-text-tertiary); cursor: pointer; font: inherit;
}
.app-notifications__mark:hover { color: var(--color-text-primary); }
.app-notifications__detail {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.app-notifications__who {
    margin: 0 0 6px;
    color: var(--color-text-tertiary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.app-notifications__detail-cta { margin: 8px 0 0; font-size: 13px; }
.app-notifications__detail-link { color: var(--color-accent-cyan); text-decoration: none; }
.app-notifications__detail-link:hover { text-decoration: underline; }
.app-notifications__empty, .app-export__empty {
    padding: var(--space-lg); color: var(--color-text-tertiary); font-size: 13px;
}

.app-notifications__prefs-help { color: var(--color-text-tertiary); font-size: 12px; margin: 0 0 10px; }
.app-notifications__prefs-table { padding: 6px 0; }
.app-notifications__prefs-row {
    display: grid;
    grid-template-columns: 1fr 52px 52px;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
}
.app-notifications__prefs-row:last-child { border-bottom: none; }
.app-notifications__prefs-row--head {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--color-text-tertiary); padding-top: 6px; padding-bottom: 6px;
}
.app-notifications__prefs-ch { text-align: center; }
.app-notifications__prefs-label strong {
    display: block; color: var(--color-text-primary); font-size: 13px;
}
.app-notifications__prefs-label span {
    display: block; color: var(--color-text-tertiary); font-size: 12px; line-height: 1.4;
}
.app-notifications__prefs-toggle {
    display: inline-flex; justify-content: center; cursor: pointer;
}
.app-notifications__prefs-toggle input { accent-color: var(--color-accent-cyan); }
.app-notifications__prefs-note {
    min-height: 18px; margin-top: 8px;
    font-size: 12px; color: var(--color-text-tertiary);
}

/* Collapsible-by-type preferences groups (2026-05-08). Native
   <details>/<summary>; one card per group, all flush so the prefs
   sidebar reads as a stack. First group renders open by default;
   the rest collapsed. */
.app-notifications__prefs-group { padding: 0; margin: 0 0 10px; overflow: hidden; }
.app-notifications__prefs-group:last-child { margin-bottom: 0; }
.app-notifications__prefs-group-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.app-notifications__prefs-group-head::-webkit-details-marker { display: none; }
.app-notifications__prefs-group-head:hover { background: var(--color-surface-2); }
.app-notifications__prefs-group-meta { display: flex; flex-direction: column; gap: 2px; }
.app-notifications__prefs-group-label {
    display: block; color: var(--color-text-primary);
    font-size: 13px; font-weight: 600;
}
.app-notifications__prefs-group-desc {
    display: block; color: var(--color-text-tertiary);
    font-size: 12px; line-height: 1.4;
}
.app-notifications__prefs-group-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 7px;
    border: 1px solid var(--color-border); border-radius: 11px;
    background: var(--color-surface-2);
    color: var(--color-text-tertiary);
    font-size: 11px; font-variant-numeric: tabular-nums;
}
.app-notifications__prefs-group-chev {
    display: inline-block;
    color: var(--color-text-tertiary);
    font-size: 12px; line-height: 1;
    transition: transform 140ms ease;
}
.app-notifications__prefs-group[open] > .app-notifications__prefs-group-head .app-notifications__prefs-group-chev {
    transform: rotate(90deg);
}
.app-notifications__prefs-group[open] > .app-notifications__prefs-group-head {
    border-bottom: 1px solid var(--color-border);
}

/* ══════════════════════════════════════════════════
   DATA EXPORT
   ══════════════════════════════════════════════════ */
.app-export__new { padding: var(--space-lg); margin-bottom: var(--space-xl); max-width: 640px; }
.app-export__form .form-group { margin-bottom: var(--space-md); }
.app-export__status {
    font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(255,255,255,0.05);
    color: var(--color-text-secondary);
}
.app-export__status--pending { background: rgba(251,191,36,0.12); color: #fbbf24; }
.app-export__status--running { background: rgba(0,235,255,0.12); color: var(--color-accent-cyan); }
.app-export__status--ready { background: rgba(74,222,128,0.12); color: #4ade80; }
.app-export__status--failed { background: rgba(220,38,38,0.12); color: #fca5a5; }
.app-export__status--expired { background: rgba(255,255,255,0.04); color: var(--color-text-tertiary); }

/* ══════════════════════════════════════════════════
   SSO
   ══════════════════════════════════════════════════ */
.app-sso__status { padding: var(--space-lg); margin-bottom: var(--space-lg); }
.app-sso__status-head {
    display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.app-sso__status-head strong { color: var(--color-text-primary); }
.app-sso__status-note { color: var(--color-text-secondary); font-size: 13px; margin: 0; line-height: 1.55; max-width: 640px; }
.app-sso__badge {
    font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 2px;
    background: rgba(255,255,255,0.04); color: var(--color-text-tertiary);
    border: 1px solid var(--color-border);
}
.app-sso__sp, .app-sso__idp { padding: var(--space-lg); margin-bottom: var(--space-lg); }
.app-sso__sp-help { color: var(--color-text-tertiary); font-size: 12px; margin: 0 0 var(--space-md); }
.app-sso__dl {
    display: grid; grid-template-columns: 220px 1fr;
    row-gap: 10px; column-gap: var(--space-md);
    margin: 0;
}
.app-sso__dl dt {
    color: var(--color-text-tertiary); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.08em; padding-top: 3px;
}
.app-sso__dl dd {
    margin: 0; color: var(--color-text-primary); font-size: 13px;
    word-break: break-all;
}
.app-sso__dl code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    color: var(--color-accent-cyan);
    background: rgba(0,0,0,0.35);
    padding: 2px 6px; border-radius: 3px;
    border: 1px solid var(--color-border);
}
.app-sso__form .form-group { margin-bottom: var(--space-md); }
.app-sso__form-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-sm); }
@media (max-width: 640px) { .app-sso__dl { grid-template-columns: 1fr; row-gap: 4px; } .app-sso__dl dt { padding-top: 10px; } }

/* Native <select> popup contrast (covers selects without the design-system
 * .form-select class — partner lead-edit etc.).  Browsers paint <option>
 * popups on their own layer; without an explicit color, dark themes can
 * render white-on-white. */
select option { background-color: #0a0a0a; color: #ffffff; }
select option:checked, select option:hover { background-color: #1a1a1a; }
[data-theme="light"] select option { background-color: #ffffff; color: #0a0a0a; }
[data-theme="light"] select option:checked, [data-theme="light"] select option:hover { background-color: #f0f0f0; }
