/* Matrix MLM Pro - Public Styles */
:root {
    --matrix-primary: #4f46e5;
    --matrix-secondary: #7c3aed;
    --matrix-success: #10b981;
    --matrix-danger: #ef4444;
    --matrix-warning: #f59e0b;
    --matrix-info: #3b82f6;
    --matrix-dark: #1f2937;
    --matrix-light: #f9fafb;
    --matrix-border: #e5e7eb;
    --matrix-radius: 8px;
    --matrix-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

/* Auth Pages */
.matrix-auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 40px 20px;
}

.matrix-auth-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--matrix-shadow);
    padding: 40px;
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--matrix-border);
}

.matrix-auth-header {
    text-align: center;
    margin-bottom: 30px;
}

/* Login-page logo. Sized to coexist with the auth-card padding
 * on phones as small as 320px wide:
 *   - The img is display:block + auto-margin instead of inline-block
 *     so centering doesn't depend on the parent's text-align cascade
 *     (some themes reset text-align inside form blocks).
 *   - max-width uses min(240px, 100%) so the image is bounded by
 *     EITHER the 240px desktop cap OR the available content width,
 *     whichever is smaller — prevents overflow when a theme leaks
 *     `width: auto` => natural-pixel rendering on a logo whose
 *     intrinsic resolution is huge (e.g. a 1500px-wide PNG uploaded
 *     for retina displays).
 *   - object-fit: contain pins aspect ratio even if a downstream
 *     rule sets explicit width/height on IMG, which WordPress's
 *     auto-attribute injection can do depending on theme/version.
 *   - Mobile breakpoint tightens both axes so a tall/square logo
 *     can't dominate the auth card on phones — 60px tall keeps
 *     vertical proportion under the heading.
 */
.matrix-auth-logo {
    margin: 0 auto 20px;
    line-height: 0;
    text-align: center;
}

.matrix-auth-logo img {
    display: block;
    margin: 0 auto;
    max-width: min(240px, 100%);
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
}

@media (max-width: 480px) {
    .matrix-auth-logo img {
        max-width: 180px;
        max-height: 60px;
    }
}

.matrix-auth-header h2 {
    font-size: 24px;
    color: var(--matrix-dark);
    margin-bottom: 8px;
}

.matrix-auth-header p {
    color: #6b7280;
    font-size: 14px;
}

.matrix-auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--matrix-border);
}

.matrix-auth-footer p {
    color: #4b5563;
    font-size: 14px;
    margin: 6px 0;
}

.matrix-auth-footer a {
    color: var(--matrix-primary);
    text-decoration: none;
    font-weight: 500;
}

.matrix-auth-footer a:hover {
    text-decoration: underline;
}

/* Forms */
.matrix-form-group {
    margin-bottom: 16px;
}

.matrix-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.matrix-form-group input,
.matrix-form-group select,
.matrix-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--matrix-border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.matrix-form-group input:focus,
.matrix-form-group select:focus,
.matrix-form-group textarea:focus {
    outline: none;
    border-color: var(--matrix-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Password reveal toggle */
.matrix-password-wrapper {
    position: relative;
}

.matrix-password-wrapper input {
    padding-right: 44px;
}

.matrix-password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #9ca3af;
    line-height: 0;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.matrix-password-toggle:hover {
    color: #374151;
}

.matrix-password-toggle:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 1px;
    background: #16a34a;
    color: #fff;
}

.matrix-password-toggle:active {
    background: #15803d;
    color: #fff;
}

/* Checkboxes and radios should not be stretched like text inputs */
.matrix-form-group input[type="checkbox"],
.matrix-form-group input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    box-shadow: none;
}

.matrix-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.matrix-form-check label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    color: #374151;
    cursor: pointer;
    margin-bottom: 0;
}

.matrix-form-check {
    margin-bottom: 20px;
}

/* Buttons */
.matrix-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.matrix-btn-primary {
    background: var(--matrix-primary);
    color: #fff;
}

.matrix-btn-primary:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

/*
 * Auth-page primary buttons (Login, Create Account).
 *
 * Scoped to .matrix-auth-card so the green palette only applies to the
 * sign-in / register CTAs and does NOT recolor every other primary
 * button in the plugin (deposits, withdrawals, ticket submits, etc.),
 * which intentionally inherit --matrix-primary.
 *
 * Palette: Tailwind green-600 -> green-700 on hover, picked to keep
 * AA contrast against the white card background and white button text.
 */
.matrix-auth-card .matrix-btn-primary {
    background: #16a34a;
}

.matrix-auth-card .matrix-btn-primary:hover {
    background: #15803d;
}

.matrix-btn-success { background: var(--matrix-success); color: #fff; }
.matrix-btn-danger { background: var(--matrix-danger); color: #fff; }
.matrix-btn-warning { background: var(--matrix-warning); color: #fff; }

.matrix-btn-block {
    width: 100%;
}

.matrix-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Plans Section */
.matrix-plans-section {
    padding: 60px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.matrix-section-header {
    text-align: center;
    margin-bottom: 40px;
}

.matrix-section-header h2 {
    font-size: 32px;
    color: var(--matrix-dark);
    margin-bottom: 10px;
}

.matrix-section-header p {
    color: #6b7280;
    font-size: 16px;
}

.matrix-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.matrix-plan-card {
    background: #fff;
    border: 1px solid var(--matrix-border);
    border-radius: 12px;
    padding: 30px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.matrix-plan-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.matrix-plan-card .plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.matrix-plan-card .plan-header h3 {
    font-size: 18px;
    color: var(--matrix-dark);
    margin: 0;
}

.plan-matrix-badge {
    background: linear-gradient(135deg, var(--matrix-primary), var(--matrix-secondary));
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.plan-price {
    margin-bottom: 20px;
}

.plan-price .price-amount {
    font-size: 36px;
    font-weight: 700;
    color: var(--matrix-primary);
}

.plan-price .price-period {
    font-size: 14px;
    color: #6b7280;
    margin-left: 4px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.plan-features li {
    padding: 8px 0;
    border-bottom: 1px solid var(--matrix-border);
    font-size: 14px;
    color: #4b5563;
}

.plan-features li:last-child {
    border-bottom: none;
}

/* Alerts */
.matrix-alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.matrix-alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.matrix-alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.matrix-alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.matrix-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Badges */
.matrix-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    line-height: 1.4;
}

.matrix-badge-active, .matrix-badge-completed, .matrix-badge-approved, .matrix-badge-credit { background: #dcfce7; color: #166534; }
.matrix-badge-pending, .matrix-badge-medium { background: #fef9c3; color: #854d0e; }
.matrix-badge-pending_capture { background: #dbeafe; color: #1e40af; }
.matrix-badge-inactive, .matrix-badge-rejected, .matrix-badge-cancelled, .matrix-badge-debit { background: #fee2e2; color: #991b1b; }
.matrix-badge-open, .matrix-badge-info, .matrix-badge-low { background: #dbeafe; color: #1e40af; }
.matrix-badge-high, .matrix-badge-urgent, .matrix-badge-customer_reply { background: #fee2e2; color: #991b1b; }
.matrix-badge-answered { background: #dcfce7; color: #166534; }
.matrix-badge-closed { background: #f1f5f9; color: #475569; }
.matrix-badge-defaulted { background: #fee2e2; color: #991b1b; }
.matrix-badge-unused { background: #dbeafe; color: #1e40af; }
.matrix-badge-used { background: #dcfce7; color: #166534; }
.matrix-badge-expired { background: #f1f5f9; color: #475569; }

.matrix-badge-source-matrix { background: #eef2ff; color: #4338ca; font-size: 9px; padding: 2px 6px; }
.matrix-badge-source-bank { background: #fef3c7; color: #92400e; font-size: 9px; padding: 2px 6px; }
.matrix-badge-source-virtual { background: #d1fae5; color: #065f46; font-size: 9px; padding: 2px 6px; }

/* Tables */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin: 16px 0;
    table-layout: auto;
}

.matrix-table thead th {
    background: #1e293b;
    color: #f1f5f9;
    padding: 12px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    border-bottom: 2px solid #334155;
}

.matrix-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    vertical-align: middle;
    line-height: 1.5;
    color: #1e293b;
}

.matrix-table tbody tr {
    transition: background 0.15s ease;
}

.matrix-table tbody tr:hover {
    background: #f8fafc;
}

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

/* Wallet transaction table */
.matrix-wallet-tx-history .matrix-table {
    table-layout: auto;
}
.matrix-wallet-tx-history .matrix-table td:nth-child(4),
.matrix-wallet-tx-history .matrix-table td:nth-child(5) {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.matrix-wallet-tx-history .matrix-table td:nth-child(4).text-success {
    color: #059669 !important;
}
.matrix-wallet-tx-history .matrix-table td:nth-child(4).text-danger {
    color: #dc2626 !important;
}
.matrix-wallet-tx-history .matrix-table td:nth-child(5) {
    color: #475569;
    font-weight: 600;
}

/* Scrollable table wrapper on small screens */
.matrix-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.matrix-table-wrap .matrix-table {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Transaction date — compact two-line display */
.matrix-tx-date {
    display: block;
    line-height: 1.3;
}
.matrix-tx-date-day {
    font-weight: 600;
    color: #1e293b;
    font-size: 12px;
}
.matrix-tx-date-time {
    font-size: 11px;
    color: #64748b;
}

/* Description cell */
.matrix-tx-desc {
    color: #475569;
    font-size: 12px;
    line-height: 1.4;
    max-width: 320px;
}

/* Dash for null values */
.matrix-tx-dash {
    color: #94a3b8;
    font-size: 14px;
}

.text-success { color: #059669 !important; font-weight: 600; }
.text-danger { color: #dc2626 !important; font-weight: 600; }

/* Info Box */
.matrix-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.matrix-info-box p {
    margin: 4px 0;
    font-size: 14px;
    color: #1e40af;
}

/* Gateway Options */
.matrix-gateway-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.matrix-gateway-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 2px solid var(--matrix-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.matrix-gateway-option:has(input:checked) {
    border-color: var(--matrix-primary);
    background: rgba(79, 70, 229, 0.05);
}

.matrix-gateway-option input[type="radio"] {
    width: auto;
    margin-bottom: 8px;
}

.gateway-name {
    font-weight: 600;
    font-size: 14px;
}

.gateway-charge {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
}

/* Form Card */
.matrix-form-card {
    background: #fff;
    border: 1px solid var(--matrix-border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

/* Referral Box */
.matrix-referral-box {
    background: linear-gradient(135deg, var(--matrix-primary), var(--matrix-secondary));
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    color: #fff;
}

.matrix-referral-box h3 {
    margin: 0 0 12px;
    color: #fff;
}

.matrix-referral-link {
    display: flex;
    gap: 8px;
}

.matrix-referral-link input {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    background: rgba(255,255,255,0.9);
}

/* Ticket Messages */
.matrix-ticket-messages {
    margin: 20px 0;
}

.matrix-message {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.matrix-message.user-reply {
    background: #f3f4f6;
    margin-right: 40px;
}

.matrix-message.admin-reply {
    background: #eff6ff;
    margin-left: 40px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.message-body {
    font-size: 14px;
    line-height: 1.6;
}

/* ============================================================
 * Notification toast (used by matrix-public.js showNotification)
 * ============================================================ */
.matrix-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.matrix-notification.show {
    transform: translateX(0);
}
.matrix-notification-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.matrix-notification-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.matrix-notification-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Responsive */
@media (max-width: 768px) {
    .matrix-form-row {
        grid-template-columns: 1fr;
    }
    .matrix-plans-grid {
        grid-template-columns: 1fr;
    }
    .matrix-gateway-options {
        grid-template-columns: 1fr;
    }
    .matrix-auth-card {
        padding: 24px;
    }
}



/* ============================================================
 * Member Benefits — dashboard tab + admin-managed card grid.
 * The modal is intentionally lightweight (no jQuery, no Bootstrap)
 * so it works even on stripped-down themes that defer or remove
 * the dashboard's main JS bundle.
 * ============================================================ */

.matrix-benefits-panel h2 {
    margin: 0 0 8px;
}
.matrix-benefits-intro {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 24px;
}

.matrix-benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

/* Match the wallet-to-wallet transfer card (.matrix-form-card):
 * white background, subtle border, 8px radius, flat 24px padding,
 * left-aligned content, no hover lift. */
.matrix-benefit-card {
    background: #fff;
    border: 1px solid var(--matrix-border);
    border-radius: 8px;
    padding: 24px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.matrix-benefit-card .benefit-icon {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 4px;
}

.matrix-benefit-card .benefit-icon .dashicons {
    color: var(--matrix-primary);
}

.matrix-benefit-card .benefit-icon img {
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
}

.matrix-benefit-card .benefit-title {
    margin: 0;
    font-size: 18px;
    color: var(--matrix-dark);
}

.matrix-benefit-card .benefit-short {
    margin: 0;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
    flex-grow: 1;
}

.matrix-benefit-card .benefit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 8px;
}

.matrix-benefit-card .matrix-benefit-readmore {
    background: transparent;
    color: var(--matrix-primary);
    border: 1px solid var(--matrix-primary);
}

.matrix-benefit-card .matrix-benefit-readmore:hover {
    background: var(--matrix-primary);
    color: #fff;
}

/* Long-description modal */
.matrix-benefit-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}

.matrix-benefit-modal.is-open {
    display: block;
}

.matrix-benefit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    cursor: pointer;
}

.matrix-benefit-modal-dialog {
    position: relative;
    max-width: 600px;
    margin: 5vh auto;
    background: #fff;
    border-radius: 12px;
    padding: 32px 32px 28px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    max-height: 85vh;
    overflow-y: auto;
}

.matrix-benefit-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
}

.matrix-benefit-modal-close:hover {
    color: #111827;
}

.matrix-benefit-modal-title {
    margin: 0 0 14px;
    color: var(--matrix-dark);
    font-size: 22px;
}

.matrix-benefit-modal-body {
    color: #374151;
    font-size: 15px;
    line-height: 1.65;
}

.matrix-benefit-modal-body p {
    margin: 0 0 12px;
}

.matrix-benefit-modal-body a {
    color: var(--matrix-primary);
}

body.matrix-benefit-modal-lock {
    overflow: hidden;
}

@media (max-width: 600px) {
    .matrix-benefit-modal-dialog {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
        max-width: 100%;
    }
}



/* ============================================================
 * CUG (Closed User Group) application form modal — opened from
 * the "Apply for CUG" button on the Benefits-tab card. Shares the
 * dimming-backdrop / centered-dialog approach with the benefit
 * read-more modal but renders an interactive form instead of a
 * read-only body, so it gets its own component scope.
 * ============================================================ */

.matrix-cug-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}

.matrix-cug-modal.is-open {
    display: block;
}

.matrix-cug-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    cursor: pointer;
}

.matrix-cug-modal-dialog {
    position: relative;
    max-width: 560px;
    margin: 5vh auto;
    background: #fff;
    border-radius: 12px;
    padding: 32px 32px 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    max-height: 90vh;
    overflow-y: auto;
}

.matrix-cug-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
}

.matrix-cug-modal-close:hover {
    color: #111827;
}

.matrix-cug-modal-title {
    margin: 0 0 6px;
    color: var(--matrix-dark);
    font-size: 22px;
}

.matrix-cug-modal-intro {
    margin: 0 0 18px;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
}

.matrix-cug-status {
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.45;
}

.matrix-cug-status-pending   { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.matrix-cug-status-approved  { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.matrix-cug-status-rejected  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.matrix-cug-status-cancelled { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.matrix-cug-form .matrix-form-group {
    margin-bottom: 14px;
}

.matrix-cug-form .matrix-form-row {
    margin-bottom: 0;
}

.matrix-cug-form .matrix-form-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: #6b7280;
}

.matrix-cug-form .matrix-form-optional {
    color: #6b7280;
    font-weight: 400;
    font-size: 12px;
    margin-left: 4px;
}

/* Required-marker asterisk inherits color from the label so it stays
 * legible in any future theme override. */
.matrix-cug-form label span[aria-hidden="true"] {
    color: var(--matrix-danger);
    margin-left: 2px;
}

.matrix-cug-form .matrix-form-group.has-error input {
    border-color: var(--matrix-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.matrix-cug-feedback {
    min-height: 0;
    margin: 4px 0 12px;
    font-size: 13px;
    line-height: 1.45;
}

.matrix-cug-feedback:empty {
    display: none;
}

.matrix-cug-feedback-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 10px 12px;
    border-radius: 6px;
}

.matrix-cug-feedback-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 6px;
}

.matrix-cug-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

body.matrix-cug-modal-lock {
    overflow: hidden;
}

@media (max-width: 600px) {
    .matrix-cug-modal-dialog {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
        max-width: 100%;
        padding: 24px 20px 20px;
    }
    .matrix-cug-actions {
        flex-direction: column-reverse;
    }
    .matrix-cug-actions .matrix-btn {
        width: 100%;
    }
}



/* ============================================================
 * Loan application modal — wider and taller than the CUG modal
 * because the form has 30+ fields across four sections plus a
 * scrolling T&Cs block. Same belt-and-braces hide pattern (HTML
 * hidden + inline display:none + .is-open class) so the modal
 * stays invisible until JS opens it, even if the cached CSS is
 * stale.
 * ============================================================ */

.matrix-loan-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}
.matrix-loan-modal.is-open {
    display: block;
}
.matrix-loan-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    cursor: pointer;
}
.matrix-loan-modal-dialog {
    position: relative;
    max-width: 760px;
    margin: 3vh auto;
    background: #fff;
    border-radius: 12px;
    padding: 32px 32px 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    max-height: 94vh;
    overflow-y: auto;
}
.matrix-loan-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
}
.matrix-loan-modal-close:hover { color: #111827; }
.matrix-loan-modal-title {
    margin: 0 0 6px;
    color: var(--matrix-dark);
    font-size: 22px;
}
.matrix-loan-modal-intro {
    margin: 0 0 18px;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
}
body.matrix-loan-modal-lock { overflow: hidden; }


.matrix-loan-status {
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.45;
}
.matrix-loan-status-pending,
.matrix-loan-status-under_review { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.matrix-loan-status-approved     { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.matrix-loan-status-rejected     { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.matrix-loan-status-cancelled    { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.matrix-loan-section {
    border: 1px solid var(--matrix-border);
    border-radius: 8px;
    padding: 18px 18px 8px;
    margin-bottom: 18px;
}
.matrix-loan-section legend {
    font-weight: 600;
    color: var(--matrix-dark);
    padding: 0 8px;
    font-size: 15px;
}
.matrix-loan-subhead {
    font-size: 13px;
    color: #4b5563;
    margin: 14px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.matrix-loan-hint {
    margin: 0 0 10px;
    font-size: 12px;
    color: #6b7280;
}
.matrix-loan-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.matrix-loan-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}
.matrix-loan-radio input[type="radio"] { width: auto; margin: 0; }
.matrix-loan-file input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--matrix-border);
    border-radius: 6px;
    background: #f9fafb;
    font-size: 13px;
}


.matrix-loan-file-current { font-size: 12px; font-weight: 400; color: #6b7280; }
.matrix-loan-file-current a { color: var(--matrix-primary); }

.matrix-loan-terms {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--matrix-border);
    border-radius: 6px;
    padding: 12px 14px;
    background: #f9fafb;
    font-size: 12px;
    line-height: 1.55;
    color: #374151;
    margin-bottom: 14px;
}
.matrix-loan-terms p { margin: 0 0 8px; }
.matrix-loan-terms p:last-child { margin-bottom: 0; }
.matrix-loan-agree {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}
.matrix-loan-agree input[type="checkbox"] {
    margin-top: 3px;
    width: auto;
}
.matrix-loan-feedback { min-height: 0; margin: 4px 0 12px; font-size: 13px; line-height: 1.45; }
.matrix-loan-feedback:empty { display: none; }
.matrix-loan-feedback-success {
    background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
    padding: 10px 12px; border-radius: 6px;
}
.matrix-loan-feedback-error {
    background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
    padding: 10px 12px; border-radius: 6px;
}
.matrix-loan-actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px;
}
.matrix-loan-form .has-error input,
.matrix-loan-form .has-error select,
.matrix-loan-form .has-error textarea {
    border-color: var(--matrix-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
@media (max-width: 600px) {
    .matrix-loan-modal-dialog {
        margin: 0; border-radius: 0; max-height: 100vh; height: 100vh;
        max-width: 100%; padding: 24px 18px;
    }
    .matrix-loan-actions { flex-direction: column-reverse; }
    .matrix-loan-actions .matrix-btn { width: 100%; }
}

/* Skeleton loading */
.matrix-skeleton { position: relative; overflow: hidden; background: #e5e7eb; border-radius: 6px; min-height: 16px; }
.matrix-skeleton::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); animation: matrix-skeleton-shimmer 1.5s infinite; }
@keyframes matrix-skeleton-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.matrix-skeleton-line { height: 14px; margin-bottom: 10px; }
.matrix-skeleton-line.w50 { width: 50%; }
.matrix-skeleton-line.w75 { width: 75%; }
.matrix-skeleton-line.w90 { width: 90%; }
.matrix-skeleton-block { height: 120px; margin-bottom: 16px; }
.matrix-tab-loading { opacity: 0.4; pointer-events: none; transition: opacity 0.2s; }

/* Confirmation modal */
.matrix-confirm-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 99999; display: flex; align-items: center; justify-content: center; }
.matrix-confirm-dialog { background: #fff; border-radius: 12px; padding: 28px; max-width: 420px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.matrix-confirm-dialog h3 { margin: 0 0 8px; font-size: 18px; color: #111827; }
.matrix-confirm-dialog p { margin: 0 0 20px; color: #4b5563; font-size: 14px; line-height: 1.5; }
.matrix-confirm-dialog .matrix-confirm-detail { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; color: #374151; }
.matrix-confirm-dialog .matrix-confirm-detail strong { display: block; margin-bottom: 4px; }
.matrix-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Offline banner */
.matrix-offline-banner { position: fixed; top: 0; left: 0; right: 0; background: #f59e0b; color: #111; text-align: center; padding: 8px 16px; font-size: 13px; font-weight: 500; z-index: 99999; transform: translateY(-100%); transition: transform 0.3s; }
.matrix-offline-banner.show { transform: translateY(0); }

/* Toast improvements */
.matrix-toast-container { position: fixed; top: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.matrix-toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 14px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto; cursor: pointer; transform: translateX(120%); transition: transform 0.3s, opacity 0.3s; max-width: 400px; display: flex; align-items: center; gap: 8px; }
.matrix-toast.show { transform: translateX(0); }
.matrix-toast-success { background: #059669; }
.matrix-toast-error { background: #dc2626; }
.matrix-toast-info { background: #2563eb; }
.matrix-toast-warning { background: #d97706; }
.matrix-toast-close { margin-left: auto; background: none; border: none; color: rgba(255,255,255,0.95); cursor: pointer; font-size: 18px; padding: 0 0 0 8px; line-height: 1; }

/* Command palette */
.matrix-cmd-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999999; display: flex; align-items: flex-start; justify-content: center; padding-top: 20vh; }
.matrix-cmd-dialog { background: #fff; border-radius: 12px; width: 90%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
.matrix-cmd-input { width: 100%; border: none; border-bottom: 1px solid #e5e7eb; padding: 16px 20px; font-size: 16px; outline: none; box-sizing: border-box; }
.matrix-cmd-results { max-height: 320px; overflow-y: auto; }
.matrix-cmd-item { padding: 10px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; color: #374151; }
.matrix-cmd-item:hover, .matrix-cmd-item.active { background: #f3f4f6; }
.matrix-cmd-item .matrix-cmd-icon { width: 20px; color: #6b7280; }
.matrix-cmd-item .matrix-cmd-hint { margin-left: auto; font-size: 11px; color: #6b7280; }
.matrix-cmd-empty { padding: 20px; text-align: center; color: #6b7280; font-size: 14px; }

/* Avatar upload progress */
.matrix-avatar-upload-wrap { position: relative; display: inline-block; }
.matrix-avatar-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(255,255,255,0.3); border-radius: 0 0 50% 50%; overflow: hidden; }
.matrix-avatar-progress-bar { height: 100%; background: var(--matrix-primary); width: 0; transition: width 0.3s; }

/* Form validation */
.matrix-form-group input.error,
.matrix-form-group select.error,
.matrix-form-group textarea.error { border-color: var(--matrix-danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }
.matrix-form-group .matrix-field-error { color: var(--matrix-danger); font-size: 12px; margin-top: 4px; display: none; }
.matrix-form-group.has-error .matrix-field-error { display: block; }

/* Cooldown timer */
.matrix-cooldown { font-size: 12px; color: #6b7280; margin-top: 4px; }
.matrix-cooldown .countdown { font-weight: 600; color: var(--matrix-primary); }

/* Empty state */
.matrix-empty-state { text-align: center; padding: 40px 20px; }
.matrix-empty-state svg { width: 64px; height: 64px; color: #d1d5db; margin-bottom: 16px; }
.matrix-empty-state h3 { font-size: 16px; color: #374151; margin: 0 0 8px; }
.matrix-empty-state p { color: #6b7280; font-size: 14px; margin: 0 0 20px; }

/* Password form improvements */
.matrix-auth-footer .matrix-auth-links { margin-bottom: 12px; }
.matrix-auth-footer .matrix-auth-links a { display: block; margin: 6px 0; }

/* Mobile nav active state */
.matrix-nav-item.active svg { opacity: 1; }
.matrix-nav-item.active { font-weight: 600; }

/* Inline validation */
.matrix-form-group.valid input,
.matrix-form-group.valid select { border-color: #059669; }
.matrix-form-group.valid input:focus,
.matrix-form-group.valid select:focus { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1); }

/* Responsive improvements */
@media (max-width: 480px) {
    .matrix-toast-container { top: auto; bottom: 80px; right: 10px; left: 10px; }
    .matrix-toast { max-width: 100%; }
    .matrix-confirm-dialog { padding: 20px; }
}

/* Dark mode additions */
.matrix-confirm-dialog { background: #fff; }
.matrix-cmd-dialog { background: #fff; }
.matrix-cmd-input { background: #fff; color: #111; }

/* Ticket message explicit text colors */
.matrix-message { color: #1f2937; }
.matrix-message .message-header { color: #374151; }
.matrix-message .message-header span { color: #6b7280; }
.matrix-message .message-body { color: #1f2937; }
.matrix-message.user-reply { background: #f3f4f6; margin-right: 40px; }
.matrix-message.admin-reply { background: #eff6ff; margin-left: 40px; }

/* Responsive — all tables */
@media (max-width: 768px) {
    .matrix-table {
        font-size: 12px;
    }
    .matrix-table thead th {
        padding: 10px;
        font-size: 10px;
    }
    .matrix-table tbody td {
        padding: 10px;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --matrix-bg: #1a1a2e;
        --matrix-surface: #16213e;
        --matrix-text: #e0e0e0;
        --matrix-text-secondary: #a0a0a0;
        --matrix-border: #2a2a4a;
        --matrix-primary: #4a9eff;
        --matrix-success: #4caf50;
        --matrix-warning: #ff9800;
        --matrix-danger: #f44336;
    }
    
    body { background: var(--matrix-bg); color: var(--matrix-text); }
    .matrix-dashboard, .matrix-card { background: var(--matrix-surface); border-color: var(--matrix-border); }
    .matrix-btn-primary { background: var(--matrix-primary); }
    input, select, textarea { background: var(--matrix-surface); color: var(--matrix-text); border-color: var(--matrix-border); }
    table { border-color: var(--matrix-border); }
    th { background: var(--matrix-surface); }
    td { border-color: var(--matrix-border); }

    /* Ticket messages */
    .matrix-message { color: var(--matrix-text); background: var(--matrix-surface); }
    .matrix-message .message-header { color: var(--matrix-text); }
    .matrix-message .message-header span { color: var(--matrix-text-secondary); }
    .matrix-message .message-body { color: var(--matrix-text); }
    .matrix-message.user-reply { background: var(--matrix-surface); }
    .matrix-message.admin-reply { background: #1a2744; }

    /* Confirm dialog */
    .matrix-confirm-dialog { background: var(--matrix-surface); }
    .matrix-confirm-dialog h3 { color: var(--matrix-text); }
    .matrix-confirm-dialog p { color: var(--matrix-text-secondary); }
    .matrix-confirm-dialog .matrix-confirm-detail { background: var(--matrix-bg); border-color: var(--matrix-border); color: var(--matrix-text); }

    /* Command palette */
    .matrix-cmd-dialog { background: var(--matrix-surface); }
    .matrix-cmd-input { background: var(--matrix-surface); color: var(--matrix-text); border-color: var(--matrix-border); }
    .matrix-cmd-item { color: var(--matrix-text); }
    .matrix-cmd-item:hover, .matrix-cmd-item.active { background: rgba(255,255,255,0.05); }
    .matrix-cmd-item .matrix-cmd-icon { color: var(--matrix-text-secondary); }
    .matrix-cmd-item .matrix-cmd-hint { color: var(--matrix-text-secondary); }
    .matrix-cmd-empty { color: var(--matrix-text-secondary); }

    /* Form elements */
    .matrix-form-card { background: var(--matrix-surface); border-color: var(--matrix-border); }

    /* Notification banners */
    .matrix-notification-success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }
    .matrix-notification-error { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
    .matrix-notification-info { background: #1e3a5f; color: #bfdbfe; border-color: #1e40af; }

    /* Messaging */
    .matrix-messaging { background: var(--matrix-surface); border-color: var(--matrix-border); }
    .matrix-messaging__sidebar { background: var(--matrix-bg); border-color: var(--matrix-border); }
    .matrix-messaging__thread { border-color: var(--matrix-border); color: var(--matrix-text); }
    .matrix-messaging__thread:hover { background: rgba(255,255,255,0.04); }
    .matrix-messaging__thread.is-active { background: rgba(79,70,229,0.15); }
    .matrix-messaging__thread strong { color: var(--matrix-text); }
    .matrix-messaging__empty, .matrix-messaging__placeholder { color: var(--matrix-text-secondary); }
    .matrix-messaging__pane { background: var(--matrix-surface); }
    .matrix-messaging__pane-header { background: var(--matrix-surface); border-color: var(--matrix-border); color: var(--matrix-text); }
    .matrix-messaging__messages { background: var(--matrix-bg); }
    .matrix-messaging__message { background: var(--matrix-surface); color: var(--matrix-text); }
    .matrix-messaging__message.is-own { background: #4f46e5; color: #fff; }
    .matrix-messaging__message-meta { color: var(--matrix-text-secondary); }
    .matrix-messaging__message.is-own .matrix-messaging__message-meta { color: rgba(255,255,255,0.9); }
    .matrix-messaging__composer { background: var(--matrix-bg); border-color: var(--matrix-border); }
    .matrix-messaging__composer-row textarea { background: var(--matrix-surface); color: var(--matrix-text); border-color: var(--matrix-border); }
    .matrix-messaging__attach-btn { background: var(--matrix-surface); color: var(--matrix-text-secondary); }
    .matrix-messaging__attach-btn:hover { background: rgba(255,255,255,0.1); color: var(--matrix-text); }
    .matrix-messaging__search-input { background: var(--matrix-surface); color: var(--matrix-text); border-color: var(--matrix-border); }
    .matrix-messaging__search-results { background: var(--matrix-surface); }
    .matrix-messaging__search-header { background: var(--matrix-bg); color: var(--matrix-text-secondary); border-color: var(--matrix-border); }
    .matrix-messaging__search-empty { color: var(--matrix-text-secondary); }
    .matrix-messaging__search-result { border-color: var(--matrix-border); }
    .matrix-messaging__search-result:hover { background: rgba(255,255,255,0.04); }
    .matrix-messaging__search-result-head strong { color: var(--matrix-text); }
    .matrix-messaging__search-result-when { color: var(--matrix-text-secondary); }
    .matrix-messaging__search-result-sender { color: var(--matrix-text-secondary); }
    .matrix-messaging__search-result-snippet { color: var(--matrix-text-secondary); }
    .matrix-messaging__typing { background: var(--matrix-bg); border-color: var(--matrix-border); color: var(--matrix-text-secondary); }
    .matrix-messaging__typing-dot { background: var(--matrix-text-secondary); }
    .matrix-messaging__menu { background: var(--matrix-surface); border-color: var(--matrix-border); }
    .matrix-messaging__menu-header { color: var(--matrix-text-secondary); border-color: var(--matrix-border); }
    .matrix-messaging__menu-item { color: var(--matrix-text); }
    .matrix-messaging__menu-item:hover { background: rgba(255,255,255,0.04); }
    .matrix-messaging__members-panel-header { background: var(--matrix-bg); border-color: var(--matrix-border); }
    .matrix-messaging__members-row { border-color: var(--matrix-border); color: var(--matrix-text); }
    .matrix-messaging__members-role { color: var(--matrix-text-secondary); }
    .matrix-messaging__members-empty { color: var(--matrix-text-secondary); }
    .matrix-messaging__message-document { background: var(--matrix-surface); border-color: var(--matrix-border); color: var(--matrix-text); }
    .matrix-messaging__message-document:hover { background: rgba(255,255,255,0.06); }
    .matrix-messaging__message-document-size { color: var(--matrix-text-secondary); }
    .matrix-messaging__message-download-icon { color: var(--matrix-text-secondary); }
    .matrix-messaging__reaction-chip { background: var(--matrix-surface); border-color: var(--matrix-border); color: var(--matrix-text); }
    .matrix-messaging__reaction-chip:hover { background: rgba(255,255,255,0.06); }
    .matrix-messaging__react-picker { background: var(--matrix-surface); border-color: var(--matrix-border); }

    /* Offline banner */
    .matrix-offline-banner { background: #92400e; color: #fef3c7; }

    /* Cooldown timer */
    .matrix-cooldown { color: var(--matrix-text-secondary); }

    /* Empty state */
    .matrix-empty-state svg { color: var(--matrix-text-secondary); }
    .matrix-empty-state h3 { color: var(--matrix-text); }
    .matrix-empty-state p { color: var(--matrix-text-secondary); }

    /* Loan */
    .matrix-loan-hint { color: var(--matrix-text-secondary); }
    .matrix-loan-file-current { color: var(--matrix-text-secondary); }
    .matrix-loan-terms { background: var(--matrix-bg); border-color: var(--matrix-border); color: var(--matrix-text); }

    /* Benefits */
    .matrix-benefits-intro { color: var(--matrix-text-secondary); }
    .matrix-benefit-card { background: var(--matrix-surface); border-color: var(--matrix-border); }
    .matrix-benefit-card .benefit-short { color: var(--matrix-text-secondary); }

    /* Gateway */
    .gateway-charge { color: var(--matrix-text-secondary); }
}
