/* ================================================
   STS - Sport Tracking System Custom CSS
   Modern Vietnamese Design
   ================================================
   Design tokens (medal colors, avatar sizes, etc.) live in:
   public/css/sts-tokens.css — loaded before this file.
   ================================================ */

:root {
    --primary-color: #0d6efd;
    --primary-dark: #0a58ca;
    --primary-light: #6ea8fe;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-bg: #f8f9fa;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --card-shadow-hover: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* =============== Global Styles =============== */
body {
    font-family: Inter, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--sts-bg-app, #edf1f7);
    color: var(--sts-text-primary, #212529);
    min-height: 100vh;
}

/* =============== Navigation =============== */
.navbar {
    background: var(--sts-navbar-bg, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    padding: 0.5625rem 0;
    border-bottom: var(--sts-navbar-border, transparent);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
}

.navbar-brand:hover {
    opacity: 0.88;
}

.nav-link {
    font-weight: 500;
    transition: background 0.15s ease;
    border-radius: 0.375rem;
    margin: 0 0.15rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* =============== Cards =============== */
.card {
    border-radius: 1rem;
    box-shadow: var(--sts-card-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
    border: var(--sts-card-border, transparent) !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: clip; /* clip visual overflow while allowing scroll inside children */
}

.card:hover {
    box-shadow: var(--sts-card-shadow-hover, 0 0.375rem 0.75rem rgba(0, 0, 0, 0.12));
    transform: translateY(-2px);
}

.card-header {
    background: var(--sts-bg-surface, #ffffff);
    color: var(--sts-text-primary, #212529);
    border: none;
    border-bottom: 1px solid var(--sts-border-subtle, #e9ecef);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
}

.card-body {
    background: var(--sts-bg-surface, #ffffff);
    padding: 1.25rem;
}

/* =============== Stats Cards =============== */
.stat-card {
    border-radius: 1rem;
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.stat-card-primary {
    background: var(--gradient-primary);
}

.stat-card-success {
    background: var(--gradient-success);
}

.stat-card-warning {
    background: var(--gradient-warning);
}

.stat-card-info {
    background: var(--gradient-info);
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

.stat-card i {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

/* =============== Buttons =============== */
.btn {
    border-radius: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
    border: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--sts-shadow-md, 0 4px 16px rgba(0, 0, 0, 0.12));
}

.btn-primary {
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
}

.btn-success {
    background: var(--sts-gradient-success, linear-gradient(135deg, #11998e 0%, #38ef7d 100%));
}

.btn-danger {
    background: var(--sts-gradient-accent, linear-gradient(135deg, #f093fb 0%, #f5576c 100%));
}

.btn-info {
    background: var(--sts-gradient-info, linear-gradient(135deg, #4facfe 0%, #00f2fe 100%));
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* =============== Tables =============== */
.table {
    background: var(--sts-bg-surface, #ffffff);
    border-radius: 0.75rem;
}

.table thead th {
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    border: none;
    font-weight: 600;
    padding: 1rem;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: var(--sts-table-hover-bg, rgba(102, 126, 234, 0.05));
}

.table-responsive {
    border-radius: 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* =============== Badges =============== */
.badge {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.85rem;
}

/* =============== Forms =============== */
.form-label {
    font-weight: 600;
    color: var(--sts-text-secondary, #495057);
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border-radius: 0.5rem;
    border: 2px solid var(--sts-input-border, #e9ecef);
    padding: 0.75rem 1rem;
    background-color: var(--sts-input-bg, #ffffff);
    color: var(--sts-text-primary, #212529);
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem var(--sts-focus-ring, rgba(102, 126, 234, 0.25));
    background-color: var(--sts-input-focus-bg, #ffffff);
    color: var(--sts-text-primary, #212529);
}

/* =============== Alerts =============== */
.alert {
    border-radius: 0.75rem;
    border: none;
    padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow);
}

.alert-success {
    background: linear-gradient(135deg, #d4f4dd 0%, #b8f2c6 100%);
    color: #0f5132;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f1aeb5 100%);
    color: #842029;
}

.alert-info {
    background: linear-gradient(135deg, #cff4fc 0%, #9eeaf9 100%);
    color: #055160;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    color: #664d03;
}

/* =============== Footer =============== */
/* .sts-footer styles are in the Page Layout System section below */
footer {
    background: var(--sts-footer-bg, #f8f9fa);
    border-top: 1px solid var(--sts-footer-border, #dee2e6);
    color: var(--sts-footer-color, #6c757d);
    font-size: 0.8125rem;
}

/* =============== Activity List =============== */
.activity-item {
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
}

.activity-item:hover {
    border-left-color: #764ba2;
    background: var(--sts-table-hover-bg, rgba(102, 126, 234, 0.04));
}

/* =============== Badge Item =============== */
.badge-item {
    text-align: center;
    padding: 1.5rem;
    border-radius: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.badge-item-earned {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.badge-item-locked {
    background: #e9ecef;
    opacity: 0.6;
}

.badge-item:hover {
    transform: translateY(-2px) scale(1.02);
}

.badge-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* =============== Group Card =============== */
.group-card {
    border-left: 4px solid #667eea;
}

.group-card:hover {
    border-left-color: #764ba2;
}

/* =============== Pagination (base) =============== */
.page-link {
    border-radius: 0.5rem;
    margin: 0 0.25rem;
    border: none;
    color: #667eea;
    font-weight: 500;
    font-size: 0.875rem;
}

/* =============== Loading Spinner =============== */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

/* =============== Responsive =============== */
@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .stat-card h3 {
        font-size: 2rem;
    }
    
    .stat-card i {
        font-size: 2rem;
    }
}

/* =============== Custom Scrollbar =============== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px; /* horizontal scrollbars (table-responsive etc.) */
}

::-webkit-scrollbar-track {
    background: var(--sts-bg-elevated, #f1f1f1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Firefox: scrollbar-color uses the same purple tone */
* {
    scrollbar-width: thin;
    scrollbar-color: #764ba2 transparent;
}

/* =============== Animations =============== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.6s ease-out;
}

/* =============== Utility Classes =============== */
.text-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-sm-hover:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.transform-scale:hover {
    transform: scale(1.05);
}

/* =============== Pagination Styling =============== */
.pagination {
    margin: 0;
}

.pagination .page-link {
    font-size: 0.875rem !important;
    padding: 0.375rem 0.75rem !important;
    line-height: 1.5 !important;
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    color: #667eea;
    border: 1px solid var(--sts-border, #dee2e6);
    background: var(--sts-bg-surface, #ffffff);
}

.pagination .page-link:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.pagination .page-item.disabled .page-link {
    font-size: 0.875rem !important;
    padding: 0.375rem 0.75rem !important;
}

/* Fix SVG icon sizing in pagination */
.pagination .page-link svg {
    width: 0.875rem;
    height: 0.875rem;
    vertical-align: middle;
}

/* =============== Health Commitment System Styles =============== */

/* Typography Standardization */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sts-text-primary, #2c3e50);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--sts-text-muted, #6c757d);
    margin-bottom: 0;
}

/* Info Box - Replacement for small-box */
.info-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.25rem;
    background: var(--sts-bg-surface, #ffffff);
    border: var(--sts-card-border, transparent);
    border-radius: 0.75rem;
    box-shadow: var(--sts-card-shadow, 0 2px 8px rgba(0, 0, 0, 0.08));
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 130px;
}

.info-box:hover {
    box-shadow: var(--sts-shadow-md, 0 4px 16px rgba(0, 0, 0, 0.12));
    transform: translateY(-2px);
}

.info-box-icon {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.15;
    transition: all 0.3s ease;
}

.info-box:hover .info-box-icon {
    opacity: 0.25;
    transform: translateY(-50%) scale(1.1);
}

.info-box-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.info-box-text {
    font-size: 0.875rem;
    color: var(--sts-text-muted, #6c757d);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Info box color variants */
.info-box-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.info-box-primary .info-box-text {
    color: rgba(255, 255, 255, 0.9);
}

.info-box-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.info-box-success .info-box-text {
    color: rgba(255, 255, 255, 0.9);
}

.info-box-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.info-box-warning .info-box-text {
    color: rgba(255, 255, 255, 0.9);
}

.info-box-danger {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.info-box-danger .info-box-text {
    color: rgba(255, 255, 255, 0.9);
}

.info-box-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.info-box-info .info-box-text {
    color: rgba(255, 255, 255, 0.9);
}

/* Widget User Replacement */
.summary-widget {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.summary-widget-header {
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    padding: 1.25rem;
}

.summary-widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.summary-widget-subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.summary-widget-body {
    background: var(--sts-bg-surface, #ffffff);
    padding: 0;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s ease;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item:hover {
    background: var(--sts-table-hover-bg, rgba(102, 126, 234, 0.04));
}

.summary-item-label {
    font-weight: 500;
    color: var(--sts-text-secondary, #495057);
    font-size: 0.9375rem;
}

.summary-item-value {
    font-weight: 600;
    font-size: 0.9375rem;
}

/* My Position Card */
.position-card {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
}

.position-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    transform: translateY(-3px);
}

.position-card-header {
    padding: 1.25rem;
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
}

.position-card-header.success {
    background: var(--sts-gradient-success, linear-gradient(135deg, #11998e 0%, #38ef7d 100%));
}

.position-card-header.warning {
    background: var(--sts-gradient-accent, linear-gradient(135deg, #f093fb 0%, #f5576c 100%));
}

.position-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.position-card-body {
    background: var(--sts-bg-surface, #ffffff);
    padding: 1.5rem;
}

.position-stat {
    text-align: center;
}

.position-stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sts-text-primary, #2c3e50);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.position-stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Detail Card */
.detail-card {
    border-radius: 0.75rem;
    background: var(--sts-bg-surface, #ffffff);
    padding: 1.5rem;
    border: var(--sts-card-border, transparent);
    box-shadow: var(--sts-card-shadow, 0 2px 8px rgba(0, 0, 0, 0.08));
}

.detail-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--sts-text-primary, #2c3e50);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-card-content {
    font-size: 0.9375rem;
    color: var(--sts-text-secondary, #495057);
    line-height: 1.6;
}

/* Table Enhancements */
.table-card {
    background: var(--sts-bg-surface, #ffffff);
    border: var(--sts-card-border, transparent);
    border-radius: 0.75rem;
    overflow: visible; /* allow inner table-responsive to scroll horizontally */
    box-shadow: var(--sts-card-shadow, 0 2px 8px rgba(0, 0, 0, 0.08));
}

.table-card .card-header {
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    padding: 1rem 1.25rem;
    border: none;
}

.table-card .card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-card .card-body {
    padding: 0;
}

.table-card .table {
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

.table tbody td {
    font-size: 0.9375rem;
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

/* Badge Sizes */
.badge {
    font-size: 0.8125rem;
    padding: 0.375rem 0.625rem;
    font-weight: 500;
}

.badge-lg {
    font-size: 0.9375rem;
    padding: 0.5rem 0.875rem;
}

/* Button Sizes Standardization */
.btn {
    font-size: 0.9375rem;
    padding: 0.625rem 1.25rem;
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 0.375rem 0.875rem;
}

.btn-lg {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
}

/* Alert Enhancements */
.alert {
    font-size: 0.9375rem;
    line-height: 1.6;
}

.alert h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.alert p {
    margin-bottom: 0;
}

/* Form Elements */
.form-label {
    font-size: 0.9375rem;
    font-weight: 600;
}

.form-control, .form-select {
    font-size: 0.9375rem;
}

/* Spacing Utilities */
.section-spacing {
    margin-bottom: 1.5rem;
}

.content-spacing {
    padding: 1.5rem 0;
}

/* Row spacing */
.row.section-spacing {
    margin-bottom: 1.5rem;
}

/* Alert spacing */
.alert {
    margin-bottom: 1.5rem;
}

/* Responsive Card Grid */
@media (max-width: 768px) {
    .info-box {
        margin-bottom: 1rem;
    }
    
    .info-box-number {
        font-size: 1.5rem;
    }
    
    .info-box-icon {
        font-size: 2rem;
    }
    
    .position-stat-number {
        font-size: 1.25rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-subtitle {
        font-size: 0.875rem;
    }
    
    .detail-card {
        margin-bottom: 1rem !important;
    }
    
    .summary-widget {
        margin-bottom: 1rem;
    }
}

/* Table Responsiveness */
@media (max-width: 768px) {
    .table {
        font-size: 0.875rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.625rem 0.75rem;
    }
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    padding: 1rem;
}

/* Card Tools Alignment */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-tools {
    margin-left: auto;
}

/* Border Utilities */
.border-right {
    border-right: 1px solid #dee2e6 !important;
}

@media (max-width: 576px) {
    .border-right {
        border-right: none !important;
        border-bottom: 1px solid #dee2e6 !important;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
}

/* =============== Card Style Override =============== */
.card {
    border-radius: var(--sts-radius-card, 1rem) !important;
    box-shadow: var(--sts-shadow-sm, 0 1px 4px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .06)) !important;
    border: var(--sts-card-border, transparent) !important;
    overflow: hidden;
    margin-bottom: 1.5rem; /* Ensure consistent spacing between cards */
    transition: box-shadow 0.16s ease, transform 0.16s ease;
}

.card:hover {
    box-shadow: var(--sts-shadow-md, 0 4px 16px rgba(0, 0, 0, 0.12)) !important;
    transform: translateY(-1px);
}

/* Lift utility — stronger card elevation on hover */
.sts-card-lift:hover {
    box-shadow: var(--sts-shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.18)) !important;
    transform: translateY(-3px);
}

/* Glass utility — frosted-glass surface */
.sts-glass {
    background: var(--sts-glass-bg, rgba(255, 255, 255, 0.70)) !important;
    border: 1px solid var(--sts-glass-border, rgba(255, 255, 255, 0.50)) !important;
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
}

.card .card-header {
    background: var(--sts-bg-surface, #ffffff);
    color: var(--sts-text-primary, #212529);
    border: none;
    border-bottom: 1px solid var(--sts-border-subtle, #e9ecef);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    border-top-left-radius: 0.75rem !important;
    border-top-right-radius: 0.75rem !important;
}

.card .card-header h5,
.card .card-header h3 {
    color: var(--sts-text-primary, #212529);
    margin: 0;
}

.card .card-body {
    background: var(--sts-bg-surface, #ffffff);
    padding: 1.25rem;
}

/* Card spacing improvements */
.card + .card {
    margin-top: 1.5rem;
}

/* Utility card variant - white header */
.card.card-white-header .card-header {
    background: var(--sts-bg-surface, #ffffff);
    color: var(--sts-text-primary, #2c3e50);
    border-bottom: 1px solid var(--sts-border, #e9ecef);
}

.card.card-white-header .card-header h5,
.card.card-white-header .card-header h3 {
    color: var(--sts-text-primary, #2c3e50);
}

/* =============== Breadcrumb Styling =============== */
.breadcrumb-container {
    background: var(--sts-bg-surface, #ffffff);
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: var(--sts-card-border, transparent);
}

.breadcrumb {
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: 0.8125rem;
}

.breadcrumb-item {
    color: var(--sts-text-muted, #6c757d);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    color: #adb5bd;
    padding: 0 0.5rem;
}

.breadcrumb-item a {
    color: #667eea;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.breadcrumb-item a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--sts-text-secondary, #495057);
    font-weight: 500;
}

.breadcrumb-item i {
    font-size: 1rem;
}

/* Responsive breadcrumb */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.875rem;
        flex-wrap: wrap;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 0.375rem;
    }
}

/* =============== Mobile Responsive Improvements =============== */

/* Scrollable tables on small screens */
@media (max-width: 768px) {
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Reduce card body padding on mobile */
    .card .card-body {
        padding: 1rem;
    }

    /* Stack row columns properly */
    .row > [class*="col-md-"] {
        margin-bottom: 0.75rem;
    }

    /* Group quick links – wrap on mobile */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Filter section in leaderboard – full width controls */
    .filter-section .form-select,
    .filter-section .form-control {
        font-size: 0.875rem;
    }

    /* Reduce display icons */
    .display-1 {
        font-size: 2.5rem !important;
    }

    /* Stat/info boxes compact */
    .stat-value,
    .info-box-number {
        font-size: 1.25rem !important;
    }

    /* Buttons inside card headers */
    .card-header .btn {
        font-size: 0.8125rem;
        padding: 0.25rem 0.5rem;
    }

    /* Pagination spacing */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* Extra-small screens (phones in portrait) */
@media (max-width: 576px) {
    /* Full-width buttons in action groups */
    .btn-group-mobile .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Input groups stack vertically */
    .input-group-mobile {
        flex-direction: column;
    }

    .input-group-mobile .form-control,
    .input-group-mobile .btn {
        border-radius: 0.375rem !important;
        width: 100%;
        margin-bottom: 0.25rem;
    }

    /* Auth/login form padding */
    .card .card-body.p-4 {
        padding: 1rem !important;
    }

    /* Page title on small screens */
    .page-title {
        font-size: 1.25rem !important;
    }

    /* Tables: hide less important columns */
    .table .d-none-xs {
        display: none !important;
    }

    /* Modal dialog full width */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* QR code image responsive */
    .img-fluid {
        max-width: 100%;
        height: auto;
    }
}

/* Rank column in leaderboard table (U-09) */
.rank-col {
    width: 50px;
    min-width: 50px;
}

/* ============================================================
   CHAT V2 — Professional Chat UI (BATCH V)
   ============================================================ */

/* -- Outer wrap -------------------------------------------- */
#chat-wrap {
    --chat-offset: 56px;
    height: calc(100vh - var(--chat-offset));
    min-height: 480px;
}
.chat-wrap {
    display: flex;
    gap: 0;
    background: var(--sts-bg-surface, #fff);
    border: 1px solid var(--sts-border, #dee2e6);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--sts-card-shadow, 0 2px 8px rgba(0,0,0,.07));
}

/* -- Chat area (left / main) ------------------------------- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--sts-chat-area-bg, #f5f7fa);
    position: relative; /* S9: anchor scroll FAB */
}

/* -- S9: Scroll-to-bottom FAB ------------------------------ */
.chat-scroll-fab {
    position: absolute;
    bottom: 90px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .88;
    transition: opacity .15s, transform .15s;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    z-index: 10;
}
.chat-scroll-fab:hover { opacity: 1; transform: translateY(-2px); }

/* -- Chat header ------------------------------------------- */
.chat-hdr {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    background: var(--sts-chat-hdr-bg, #fff);
    border-bottom: 1px solid var(--sts-chat-hdr-border, #e9ecef);
    flex-shrink: 0;
    min-height: 56px;
}
.chat-hdr__center { flex: 1; min-width: 0; }
.chat-hdr__name {
    font-weight: 600;
    font-size: .97rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-hdr__sub { font-size: .78rem; color: var(--sts-text-muted, #6c757d); }

/* -- Messages area ----------------------------------------- */
.chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scroll-behavior: smooth;
}

/* -- Message groups ---------------------------------------- */
.cm-group {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    max-width: 78%;
}
.cm-group--in  { align-self: flex-start; }
.cm-group--out { align-self: flex-end; flex-direction: row-reverse; }
.cm-group + .cm-group { margin-top: .3rem; }
.cm-group + .cm-sys,
.cm-sys + .cm-group { margin-top: .75rem; }

/* -- Avatar ------------------------------------------------ */
.cm-av {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    align-self: flex-start;
}
.cm-av img { width: 100%; height: 100%; object-fit: cover; }
.cm-av--sm { width: 30px; height: 30px; font-size: .7rem; }
.cm-av-md  { width: 40px; height: 40px; font-size: .8rem; }
.cm-av-lg  { width: 56px; height: 56px; font-size: 1rem;  }

/* -- Group body -------------------------------------------- */
.cm-g-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    max-width: 100%;
}
.cm-g-name {
    font-size: .72rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 2px;
    padding-left: 3px;
}

/* -- Bubbles ----------------------------------------------- */
.cm-bubble {
    position: relative;
    max-width: 100%;
    word-break: break-word;
}
.cm-bubble--in {
    background: var(--sts-chat-bubble-in, #ffffff);
    border: 1px solid var(--sts-chat-in-border, #e9ecef);
    border-radius: 4px 18px 18px 18px;
    padding: .5rem .85rem .4rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    color: var(--sts-chat-in-color, #212529);
}
.cm-bubble--out {
    background: var(--sts-chat-bubble-out, linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%));
    border-radius: 18px 4px 18px 18px;
    padding: .5rem .85rem .4rem;
    color: var(--sts-chat-bubble-out-color, #ffffff);
    box-shadow: 0 2px 6px rgba(13,110,253,.3);
}

/* -- Message content --------------------------------------- */
.cm-text { line-height: 1.5; font-size: .9rem; }
.cm-recalled { font-style: italic; opacity: .55; font-size: .85rem; }

/* -- Metadata row ------------------------------------------ */
.cm-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .3rem;
    margin-top: 3px;
}
.cm-time { font-size: .67rem; color: #868e96; white-space: nowrap; } /* Batch A: #868e96 on #f8f9fa = 4.55:1 (WCAG AA) */

/* -- Action buttons (hover reveal) ------------------------- */
.cm-acts {
    display: flex;
    align-items: center;
    gap: 1px;
    opacity: 0;
    transition: opacity .15s;
}
.cm-bubble:hover .cm-acts,
.cm-bubble:focus-within .cm-acts { opacity: 1; }
.cm-act {
    appearance: none;
    background: none;
    border: none;
    padding: 2px 5px;
    font-size: .8rem;
    cursor: pointer;
    border-radius: 6px;
    color: inherit;
    opacity: .7;
    line-height: 1;
}
.cm-act:hover { opacity: 1; background: rgba(0,0,0,.08); }
.cm-bubble--out .cm-act:hover { background: rgba(255,255,255,.2); }

/* -- Dropdown menu ----------------------------------------- */
.cm-more-dd { display: inline-flex; }
.dropdown-menu-sm .dropdown-item { font-size: .85rem; padding: .35rem .9rem; }

/* -- Reactions --------------------------------------------- */
.cm-rxns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.cm-rxn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--sts-rxn-bg, #f1f3f5);
    border: 1px solid var(--sts-rxn-border, #dee2e6);
    border-radius: 20px;
    padding: 2px 7px;
    font-size: .82rem;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    line-height: 1.4;
    color: var(--sts-rxn-color, #212529);
}
.cm-rxn:hover { background: var(--sts-dropdown-hover, #e9ecef); border-color: var(--sts-border, #adb5bd); }
.cm-rxn--mine { background: var(--sts-rxn-mine-bg, #dbeafe); border-color: var(--sts-rxn-mine-border, #93c5fd); }
.cm-rxn--mine:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.cm-rxn--mine:hover .cm-rxn-count::after { content: ' ✕'; font-size: 0.65em; }
.cm-rxn-count { font-size: .73rem; color: var(--sts-text-secondary, #495057); }

/* -- System messages --------------------------------------- */
.cm-sys {
    align-self: center;
    text-align: center;
    margin: .6rem 0;
}
.cm-sys__pill {
    display: inline-block;
    background: var(--sts-chat-system-pill, #e9ecef);
    color: var(--sts-chat-system-color, #6c757d);
    border-radius: 20px;
    padding: .3rem 1.1rem;
    font-size: .8rem;
}

/* -- Emoji reaction picker --------------------------------- */
.rxn-picker {
    position: fixed;
    background: var(--sts-rxn-picker-bg, #fff);
    border: 1px solid var(--sts-border, #dee2e6);
    border-radius: 32px;
    padding: .3rem .45rem;
    display: flex;
    gap: 3px;
    box-shadow: 0 4px 18px rgba(0,0,0,.13);
    z-index: 1060;
}
.rxn-picker__btn {
    background: none;
    border: none;
    font-size: 1.45rem;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 8px;
    transition: transform .15s, background .12s;
    line-height: 1;
}
.rxn-picker__btn:hover { transform: scale(1.3); background: #f1f3f5; }

/* -- Input bar --------------------------------------------- */
.chat-input-bar {
    background: var(--sts-chat-input-bg, #fff);
    border-top: 1px solid var(--sts-border, #e9ecef);
    padding: .6rem .85rem;
    flex-shrink: 0;
}
.chat-input-bar form {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
}
.chat-input-field {
    flex: 1;
    resize: none;
    border-radius: 22px;
    padding: .5rem 1rem;
    max-height: 120px;
    overflow-y: auto;
    font-size: .92rem;
    line-height: 1.5;
    border-color: var(--sts-input-border, #dee2e6);
    background: var(--sts-input-bg, #ffffff);
    color: var(--sts-text-primary, #212529);
}
.chat-input-field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 .2rem var(--sts-focus-ring, rgba(13,110,253,.15));
    outline: none;
}
.btn-icon-round {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.chat-send-btn {
    background: #0d6efd;
    color: #fff;
    border: none;
    transition: background .15s, opacity .15s;
}
.chat-send-btn:hover:not(:disabled) { background: #0a58ca; color: #fff; }
.chat-send-btn:disabled { background: #adb5bd; opacity: .7; cursor: not-allowed; }

/* -- Attachment preview ------------------------------------ */
.chat-attach-preview {
    padding: .35rem .85rem .2rem;
}
.chat-attach-chip {
    display: inline-flex;
    align-items: center;
    background: #e9ecef;
    border-radius: 20px;
    padding: .22rem .75rem;
    font-size: .82rem;
    max-width: 100%;
    gap: .35rem;
}
.chat-attach-thumb {
    max-height: 80px;
    max-width: 120px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #dee2e6;
    margin-top: .35rem;
    display: block;
}

/* -- Empty state ------------------------------------------- */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    user-select: none;
}
.chat-empty__icon { font-size: 3.5rem; line-height: 1; margin-bottom: .85rem; color: #adb5bd; }
.chat-empty__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: .35rem;
}
.chat-empty__sub { font-size: .88rem; color: #adb5bd; margin-bottom: .9rem; }

/* -- Members panel (desktop sidebar) ----------------------- */
.chat-members {
    width: 230px;
    min-width: 190px;
    background: var(--sts-chat-members-bg, #fff);
    border-left: 1px solid var(--sts-border, #e9ecef);
    flex-direction: column;
    flex-shrink: 0;
}
.chat-members__hdr {
    padding: .7rem 1rem;
    font-weight: 600;
    font-size: .84rem;
    color: var(--sts-text-secondary, #495057);
    background: var(--sts-bg-elevated, #f8f9fa);
    border-bottom: 1px solid var(--sts-border, #e9ecef);
    flex-shrink: 0;
}
.chat-members__list {
    flex: 1;
    overflow-y: auto;
    padding: .5rem;
}
.chat-member-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .45rem;
    border-radius: 8px;
    transition: background .12s;
    cursor: default;
}
.chat-member-row:hover { background: #f8f9fa; }
.chat-member-row__name { font-size: .83rem; font-weight: 500; line-height: 1.2; }
.chat-member-row__info { min-width: 0; }
.cm-role-badge {
    font-size: .64rem;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: capitalize;
    display: inline-block;
}
.cm-role-badge--admin  { background: #dbeafe; color: #1d4ed8; }
.cm-role-badge--leader { background: #ede9fe; color: #7c3aed; }

/* -- Attachment content in bubbles ------------------------- */
.cm-attach { font-size: .88rem; }
.cm-img-preview {
    max-width: 220px;
    max-height: 180px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    margin-bottom: .35rem;
}
.cm-video-preview {
    max-width: 280px;
    width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: .35rem;
}
.cm-audio-preview {
    max-width: 280px;
    width: 100%;
    margin-bottom: .35rem;
}
.cm-bubble--out .cm-attach { color: rgba(255,255,255,.95); }
.cm-bubble--out .cm-attach a { color: rgba(255,255,255,.8); }

/* -- Mobile ------------------------------------------------ */
@media (max-width: 767px) {
    #chat-wrap { --chat-offset: 58px; min-height: 360px; }
    .cm-group { max-width: 92%; }
    .chat-input-field { font-size: .88rem; }
    .rxn-picker { flex-wrap: wrap; max-width: 200px; border-radius: 14px; }
    .chat-hdr { padding: .55rem .75rem; }
    .chat-msgs { padding: .85rem .65rem; }
    .chat-input-bar { padding: .5rem .65rem; }
    /* S10: Mobile – larger tap targets */
    .cm-act { padding: 4px 8px; min-width: 32px; min-height: 32px; }
    .chat-scroll-fab { bottom: 80px; right: 12px; }
    .cm-video-preview { max-width: 100%; }
    .cm-audio-preview { max-width: 100%; }
}

/* ── S3: Typography system ────────────────────────────────── */
:root {
    --sts-font-base:   'Inter', system-ui, sans-serif;
    --sts-font-mono:   ui-monospace, 'Cascadia Code', monospace;
    --sts-text-xs:     .75rem;
    --sts-text-sm:     .875rem;
    --sts-text-base:   1rem;
    --sts-text-lg:     1.125rem;
    --sts-lh-tight:    1.3;
    --sts-lh-normal:   1.5;
    --sts-lh-loose:    1.75;
}
body { font-family: var(--sts-font-base); line-height: var(--sts-lh-normal); }

/* ── S4: Spacing tokens ──────────────────────────────────── */
:root {
    --sts-space-1: .25rem;
    --sts-space-2: .5rem;
    --sts-space-3: .75rem;
    --sts-space-4: 1rem;
    --sts-space-6: 1.5rem;
    --sts-space-8: 2rem;
}

/* ── S6: Empty state pattern ─────────────────────────────── */
.sts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--sts-empty-text, #6c757d);
}
.sts-empty__icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: var(--sts-empty-opacity, .35);
}
.sts-empty__title { font-size: 1.05rem; font-weight: 600; margin-bottom: .35rem; color: var(--sts-text-secondary, #495057); }
.sts-empty__sub   { font-size: .88rem; margin-bottom: 1.25rem; max-width: 320px; }

/* ── S7: Loading spinner utility ─────────────────────────── */
.sts-spinner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.65);
    backdrop-filter: blur(2px);
    z-index: 20;
}
[data-bs-theme="dark"] .sts-spinner-overlay { background: rgba(0,0,0,.45); }

/* ── S8: Skeleton loading ────────────────────────────────── */
.sts-skeleton {
    background: linear-gradient(90deg,
        var(--sts-skel-base, #e9ecef) 25%,
        var(--sts-skel-hi, #dee2e6) 50%,
        var(--sts-skel-base, #e9ecef) 75%);
    background-size: 200% 100%;
    animation: sts-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes sts-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.sts-skel-line   { height: .85rem; margin-bottom: .5rem; }
.sts-skel-circle { border-radius: 50%; }

/* ═══════════════════════════════════════════════════════════
   TOKEN-DRIVEN OVERRIDES — custom components
   These supplement inline token usage above. Kept here for
   components that still have two-rule cascade situations.
   Bootstrap handles its own components automatically via
   the data-bs-theme="dark" attribute on <html>.
   ═══════════════════════════════════════════════════════════ */

/* -- Body / page background -------------------------------- */
body {
    background: var(--sts-bg-app, #edf1f7);
    color: var(--sts-text-primary, #212529);
}

/* -- Breadcrumb -------------------------------------------- */
.breadcrumb-container { background: var(--sts-bg-surface, #fff); border-color: var(--sts-border, #dee2e6); }
.breadcrumb-item.active { color: var(--sts-text-primary, #212529); }
.page-title    { color: var(--sts-text-primary, #212529); }
.page-subtitle { color: var(--sts-text-muted, #6c757d); }

/* -- Footer ------------------------------------------------ */
footer {
    background-color: var(--sts-footer-bg, #f8f9fa) !important;
    border-top: 1px solid var(--sts-footer-border, #dee2e6);
    color: var(--sts-footer-color, #6c757d);
}

/* -- Code / pre -------------------------------------------- */
code, samp {
    background: var(--sts-code-bg, #f8f9fa);
    color: var(--sts-code-color, #d63384);
    border-radius: 4px;
    padding: .1em .35em;
    font-size: .88em;
}

/* -- Chat g-name + time ----------------------------------- */
.cm-g-name  { color: var(--sts-text-muted, #6c757d); }
.cm-time    { color: var(--sts-text-muted, #868e96); }

/* -- Notification / info-box: ensure border token applied - */
.info-box {
    border: var(--sts-card-border, transparent);
}

/* -- Tables: ensure surface token applies over white -------- */
.table { background: var(--sts-bg-surface, #fff); }

/* -- Summary widget / position / detail / table cards ------ */
.summary-widget-body { background: var(--sts-bg-surface, #fff); }
.summary-item        { border-bottom-color: var(--sts-border-subtle, #e9ecef); }
.summary-item-label  { color: var(--sts-text-secondary, #495057); }
.position-card-body  { background: var(--sts-bg-surface, #fff); }
.position-stat-number { color: var(--sts-text-primary, #212529); }
.detail-card         { background: var(--sts-bg-surface, #fff); }
.detail-card-title   { color: var(--sts-text-primary, #212529); }
.detail-card-content { color: var(--sts-text-secondary, #495057); }
.table-card          { background: var(--sts-bg-surface, #fff); }

/* -- Badges: locked badge adapts to dark surface ---------- */
.badge-item-locked { background: var(--sts-bg-elevated, #e9ecef); }

/* -- Scrollbar: track adapts to dark background ----------- */
::-webkit-scrollbar-track { background: var(--sts-bg-elevated, #f1f1f1); }

/* ═══════════════════════════════════════════════════════════
   T3: DARK MODE — premium visual overrides
   Applied only when data-bs-theme="dark" is set on <html>.
   Bootstrap 5.3 handles its own components; we supplement
   here for custom and overridden components.
   ═══════════════════════════════════════════════════════════ */

[data-bs-theme="dark"] {
    /* Navbar: token value switches (see sts-tokens.css) */
    .navbar {
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    }

    /* Card headers: muted dark gradient instead of bright purple */
    .card .card-header,
    .card.card-white-header .card-header {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%) !important;
        color: #e9ecef !important;
        border-bottom: 1px solid var(--sts-border, #2d3748);
    }
    .card .card-header h5,
    .card .card-header h3 {
        color: #e9ecef !important;
    }

    /* Table headers: dark surface gradient */
    .table thead th {
        background: linear-gradient(135deg, #1e2533 0%, #161b25 100%);
        color: #adb5bd;
        border-bottom: 1px solid var(--sts-border, #2d3748);
    }

    /* Summary widget header: dark variant */
    .summary-widget-header {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%);
    }

    /* Position / leaderboard card headers */
    .position-card-header {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%);
    }
    .position-card-header.success {
        background: linear-gradient(135deg, #0d3d31 0%, #12523f 100%);
    }
    .position-card-header.warning {
        background: linear-gradient(135deg, #4a1a2c 0%, #3a1040 100%);
    }

    /* table-card card-header */
    .table-card .card-header {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%);
        color: #e9ecef;
    }

    /* Alerts: deep dark backgrounds with colored text */
    .alert-success {
        background: linear-gradient(135deg, #0a2e1a 0%, #0f3d24 100%);
        color: #75e09a;
        border: 1px solid #1a5c35;
    }
    .alert-danger {
        background: linear-gradient(135deg, #2e0a0e 0%, #3d0f14 100%);
        color: #f08090;
        border: 1px solid #5c1a22;
    }
    .alert-info {
        background: linear-gradient(135deg, #0a1e2e 0%, #0f2b3d 100%);
        color: #6bc8e8;
        border: 1px solid #1a4a5c;
    }
    .alert-warning {
        background: linear-gradient(135deg, #2e1f0a 0%, #3d2a0f 100%);
        color: #e0bb60;
        border: 1px solid #5c3f1a;
    }

    /* Activity items and group cards: dark hover */
    .activity-item:hover   { background: rgba(255,255,255,.04); }
    .chat-member-row:hover { background: rgba(255,255,255,.06); }

    /* Chat members header */
    .chat-members__hdr     { background: var(--sts-bg-elevated, #1e2533); border-bottom-color: var(--sts-border, #2d3748); color: var(--sts-text-secondary, #adb5bd); }
    .chat-member-row__name { color: var(--sts-text-primary, #e9ecef); }

    /* Chat attach chip */
    .chat-attach-chip { background: var(--sts-bg-elevated, #1e2533); }

    /* Spinner overlay */
    .sts-spinner-overlay { background: rgba(0,0,0,.55); }

    /* Chat empty state */
    .chat-empty__icon  { color: var(--sts-text-muted, #6c757d); }
    .chat-empty__title { color: var(--sts-text-secondary, #adb5bd); }
    .chat-empty__sub   { color: var(--sts-text-muted, #6c757d); }

    /* Role badges in chat members: dark variants */
    .cm-role-badge--admin  { background: #1d3557; color: #90c5f8; }
    .cm-role-badge--leader { background: #2e1e4e; color: #c4a8f5; }

    /* Pagination: dark surface links */
    .pagination .page-link {
        background: var(--sts-bg-surface, #161b25);
        color: #7ca7f5;
        border-color: var(--sts-border, #2d3748);
    }
    .pagination .page-link:hover {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%);
        color: #e9ecef;
        border-color: transparent;
    }
    .pagination .page-item.active .page-link {
        background: linear-gradient(135deg, #2d3456 0%, #1e2438 100%);
        border-color: transparent;
        color: #e9ecef;
    }

    /* Summary item hover: dark tone */
    .summary-item:hover { background: var(--sts-table-hover-bg, rgba(255,255,255,.04)); }

    /* Position stat label */
    .position-stat-label { color: var(--sts-text-muted, #6c757d); }

    /* Info-box text */
    .info-box-text { color: var(--sts-text-muted, #6c757d); }

    /* Scrollbar — keep purple gradient in dark mode, just darken the track */
    ::-webkit-scrollbar-track { background: var(--sts-bg-page, #0a0d14); }
    ::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    * { scrollbar-color: #764ba2 #0a0d14; }
}

/* ═══════════════════════════════════════════════════════════
   FINAL UI POLISH — Phases 1–9
   Premium SaaS visual refinement pass.
   All rules use tokens from sts-tokens.css.
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────
   PHASE 1 — VISUAL HIERARCHY & VERTICAL RHYTHM
   ───────────────────────────────────────────────────────── */

/* Section-level separation — 32px top margin */
.sts-section {
    margin-top: 2rem;
}

/* Page-level content area: 24px top padding if layout doesn't set it */
main > .container,
main > .container-fluid {
    padding-top: 0.25rem;
}

/* Consistent card padding via body padding */
.card > .card-body {
    padding: 1.25rem 1.5rem;
}

/* Row grid gap for stat/summary grids */
.row.sts-grid { gap: 0; }
.row.sts-grid > [class*="col-"] { margin-bottom: 1.5rem; }

/* Tighten section-title bottom margin */
.section-title-wrapper { margin-bottom: 1.25rem; }

/* ─────────────────────────────────────────────────────────
   PHASE 2 — PREMIUM CARD SYSTEM
   ───────────────────────────────────────────────────────── */

/* Base card: token-driven surface, radius, and shadow */
.card {
    background: var(--sts-surface-elevated, #ffffff);
    border-radius: var(--sts-radius-card, 1rem) !important;
    box-shadow: var(--sts-shadow-sm) !important;
    border: var(--sts-card-border, transparent) !important;
    transition: box-shadow 0.16s ease, transform 0.16s ease;
}

/* Subtle lift on hover (all cards) */
.card:hover {
    box-shadow: var(--sts-shadow-md) !important;
    transform: translateY(-1px);
}

/* Feature card stronger lift */
.sts-card-lift:hover {
    box-shadow: var(--sts-shadow-lg) !important;
    transform: translateY(-3px);
}

/* Card header consistent padding */
.card .card-header {
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

/* Glass card utility */
.sts-glass {
    background: var(--sts-glass-bg, rgba(255,255,255,.70)) !important;
    border: 1px solid var(--sts-glass-border, rgba(255,255,255,.50)) !important;
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
}

/* ─────────────────────────────────────────────────────────
   PHASE 3 — DASHBOARD HERO METRIC CARDS
   ───────────────────────────────────────────────────────── */

/* Hero metric wrapper */
.sts-hero-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Each metric tile */
.sts-metric-tile {
    background: var(--sts-surface-elevated, #ffffff);
    border-radius: var(--sts-radius-card, 1rem);
    box-shadow: var(--sts-shadow-sm);
    border: 1px solid var(--sts-border-soft, rgba(0,0,0,.06));
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.16s ease, transform 0.16s ease;
}
.sts-metric-tile:hover {
    box-shadow: var(--sts-shadow-md);
    transform: translateY(-2px);
}
.sts-metric-tile__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sts-text-muted, #6c757d);
    margin-bottom: 0.35rem;
}
.sts-metric-tile__value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--sts-text-primary, #212529);
    margin-bottom: 0.15rem;
}
.sts-metric-tile__sub {
    font-size: 0.8rem;
    color: var(--sts-text-muted, #6c757d);
}
/* Coloured accent bar at top of tile */
.sts-metric-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--sts-gradient-primary);
    border-radius: var(--sts-radius-card, 1rem) var(--sts-radius-card, 1rem) 0 0;
}
.sts-metric-tile--success::before { background: var(--sts-gradient-success); }
.sts-metric-tile--accent::before  { background: var(--sts-gradient-accent); }
.sts-metric-tile--info::before    { background: var(--sts-gradient-info); }
.sts-metric-tile--warning::before { background: var(--sts-gradient-warning); }

/* Ghost icon decoration inside tile */
.sts-metric-tile__bg-icon {
    position: absolute;
    bottom: -0.5rem;
    right: 0.75rem;
    font-size: 3rem;
    opacity: 0.07;
    pointer-events: none;
    line-height: 1;
}

/* Info-box hover: use tokens */
.info-box:hover {
    box-shadow: var(--sts-shadow-md);
}

/* ================================================
   PAGE LAYOUT SYSTEM
   Consistent spacing, page-header, breadcrumb,
   footer, and legacy compatibility shims.
   ================================================ */

/* ── Page content wrapper ── */
.sts-page-content {
    padding-top: 1rem;
    padding-bottom: 2rem;
}

@media (max-width: 767.98px) {
    .sts-page-content {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* ── Standard section gap helpers ── */
.sts-section  { margin-bottom: 1.75rem; }
.sts-section-sm { margin-bottom: 1rem; }

/* section-spacing: backward-compat alias used in dashboard views */
.section-spacing { margin-bottom: 1.75rem; }

/* table-card: legacy div wrapper used in group sub-pages
   Gives consistent card-like appearance without using x-sts.card component */
.table-card {
    background: var(--sts-bg-surface, #ffffff);
    border-radius: var(--sts-radius-card, 0.75rem);
    box-shadow: var(--sts-card-shadow, 0 1px 4px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06));
    overflow: visible; /* keep visible so inner table-responsive can scroll horizontally */
    margin-bottom: 1.5rem;
}

/* ── Page Header ── */
.sts-page-header {
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;  /* 24px — design system standard gap between header and content */
    border-bottom: 1px solid var(--sts-border-subtle, #e9ecef);
}

.sts-page-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sts-page-title-area {
    flex: 1 1 0;
    min-width: 0;
}

.sts-page-title {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--sts-text-primary, #212529);
    margin: 0;
    letter-spacing: -0.01em;
}

.sts-page-title-icon {
    color: var(--sts-text-muted, #6c757d);
    font-size: 1.15rem;
    margin-right: 0.45rem;
    vertical-align: -0.1em;
}

.sts-page-subtitle {
    font-size: 0.875rem;
    color: var(--sts-text-muted, #6c757d);
    margin: 0.25rem 0 0 0;
    line-height: 1.5;
}

.sts-page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── STS Breadcrumb (inside sts-page-header) ── */
.sts-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0;
    margin: 0 0 0.5rem 0;  /* 8px below breadcrumb → title */
    list-style: none;
    background: transparent;
    font-size: 0.775rem;
    line-height: 1.4;
}

.sts-bc-item {
    display: flex;
    align-items: center;
    color: var(--sts-text-muted, #6c757d);
}

.sts-bc-item + .sts-bc-item::before {
    content: "/";
    padding: 0 0.35rem;
    color: var(--sts-border, #dee2e6);
    font-size: 0.65rem;
    line-height: 1;
}

.sts-bc-item a {
    color: var(--sts-text-muted, #6c757d);
    text-decoration: none;
    transition: color 0.15s ease;
}

.sts-bc-item a:hover {
    color: var(--sts-text-primary, #212529);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sts-bc-active {
    color: var(--sts-text-secondary, #495057);
    font-weight: 500;
}

@media (max-width: 575.98px) {
    .sts-page-header {
        padding-bottom: 0.75rem;
        margin-bottom: 1.25rem;
    }
    .sts-page-title {
        font-size: 1.2rem;
    }
    .sts-page-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .sts-breadcrumb {
        font-size: 0.725rem;
    }
}

/* ── Dark mode adjustments ── */
[data-bs-theme="dark"] .sts-page-header {
    border-bottom-color: var(--sts-border-subtle, #2d3748);
}

[data-bs-theme="dark"] .sts-bc-item a {
    color: var(--sts-text-muted);
}

[data-bs-theme="dark"] .card .card-header {
    background: var(--sts-bg-elevated, #1e2536);
    border-bottom-color: var(--sts-border, #2d3748);
    color: var(--sts-text-primary, #e2e8f0);
}

[data-bs-theme="dark"] .card .card-header h5,
[data-bs-theme="dark"] .card .card-header h3 {
    color: var(--sts-text-primary, #e2e8f0);
}

/* ── Footer ── */
.sts-footer {
    background: var(--sts-footer-bg, #f8f9fa);
    border-top: 1px solid var(--sts-footer-border, #dee2e6);
    color: var(--sts-footer-color, #6c757d);
    padding: 1rem 0;
    font-size: 0.8125rem;
    margin-top: 0;
}

/* ── Notification badge (navbar bell) ── */
.nav-notif-badge {
    font-size: 0.6rem !important;
    min-width: 1.1rem;
    padding: 0.18rem 0.3rem !important;
    line-height: 1.2;
    top: 4px !important;
    right: -4px !important;
    transform: none !important;
}

/* ─────────────────────────────────────────────────────────
   PHASE 4 — LEADERBOARD UI ENHANCEMENT
   ───────────────────────────────────────────────────────── */

/* Filter section: use gradient token, subtle shadow */
.filter-section {
    background: var(--sts-gradient-primary) !important;
    border-radius: var(--sts-radius-card, 1rem);
    box-shadow: var(--sts-shadow-md);
    padding: 1.25rem 1.5rem !important;
    margin-bottom: 1.5rem !important;
}

/* Top 3 row highlights */
.leaderboard-table tr.lb-rank-1 td { background: rgba(255, 215, 0, 0.08) !important; }
.leaderboard-table tr.lb-rank-2 td { background: rgba(192, 192, 192, 0.08) !important; }
.leaderboard-table tr.lb-rank-3 td { background: rgba(205, 127, 50, 0.08) !important; }

/* Avatar ring for admin/leader */
.lb-av-ring {
    border: 2px solid var(--sts-medal-gold, #FFD700);
    padding: 1px;
}
.lb-av-ring--leader {
    border-color: var(--sts-medal-silver, #C0C0C0);
}

/* Stat summary cards in leaderboard: lift on hover */
.stat-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--sts-shadow-md) !important;
}

/* Leaderboard row spacing */
.leaderboard-table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

/* Numeric columns right-align */
.leaderboard-table td.sts-num,
.leaderboard-table th.sts-num {
    text-align: right;
}

/* My position card: cleaner gradient via token */
.my-position {
    background: var(--sts-gradient-primary) !important;
    border: 2px solid var(--sts-medal-gold, #FFD700) !important;
}

/* ─────────────────────────────────────────────────────────
   PHASE 5 — CHAT VISUAL POLISH
   ───────────────────────────────────────────────────────── */

/* Fade-in for newly appended messages */
@keyframes sts-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cm-group.sts-msg-new {
    animation: sts-msg-in 0.2s ease-out both;
}

/* Slightly more bubble padding */
.cm-bubble--in,
.cm-bubble--out {
    padding: 0.6rem 1rem 0.45rem;
}

/* Avatar consistent sizing */
.cm-av { border-radius: 50%; flex-shrink: 0; }

/* Media previews as cards */
.cm-img-preview {
    border-radius: 0.75rem;
    box-shadow: var(--sts-shadow-xs);
    max-width: 240px;
    max-height: 200px;
}
.cm-video-preview {
    border-radius: 0.75rem;
    box-shadow: var(--sts-shadow-xs);
}

/* Chat members panel refinement */
.chat-members {
    border-left: 1px solid var(--sts-border-soft, rgba(0,0,0,.06));
}

/* Message group gap */
.cm-group { margin-bottom: 0.25rem; }

/* ─────────────────────────────────────────────────────────
   PHASE 6 — TABLE VISUAL POLISH
   ───────────────────────────────────────────────────────── */

/* Token-based table header */
.table thead th {
    background: var(--sts-gradient-primary) !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-width: 0 !important;
    white-space: nowrap;
}

/* Row hover: background only, no layout shift */
.table tbody tr {
    transition: background 0.12s ease;
}
.table tbody tr:hover {
    background: var(--sts-table-hover-bg, rgba(102,126,234,.05));
    transform: none !important; /* Cancel any scale */
}

/* Consistent row height */
.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.9375rem;
}

/* Numeric right-align utility */
td.sts-num, th.sts-num { text-align: right; }

/* Rounded table wrapper with scroll-shadow hint */
.table-responsive {
    border-radius: var(--sts-radius-card, 1rem);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    box-shadow: var(--sts-shadow-sm);
}

/* Right-edge gradient: signals that the table scrolls horizontally */
.table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.07));
    border-radius: 0 var(--sts-radius-card, 1rem) var(--sts-radius-card, 1rem) 0;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.25s ease;
}

/* Hide shadow when table is fully scrolled to the right end */
.table-responsive.sts-scroll-end::after {
    opacity: 0;
}

/* Dark mode: slightly stronger shadow hint */
[data-bs-theme="dark"] .table-responsive::after {
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.18));
}

/* ─────────────────────────────────────────────────────────
   PHASE 7 — EMPTY STATE DESIGN
   ───────────────────────────────────────────────────────── */

/* Shared empty state wrapper */
.sts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1.5rem;
    text-align: center;
}
.sts-empty__icon {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 1rem;
    opacity: 0.25;
    color: var(--sts-text-muted, #6c757d);
}
.sts-empty__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--sts-text-primary, #212529);
    margin-bottom: 0.4rem;
}
.sts-empty__body {
    font-size: 0.9rem;
    color: var(--sts-text-muted, #6c757d);
    max-width: 320px;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────
   PHASE 8 — MICRO-INTERACTION REFINEMENTS
   ───────────────────────────────────────────────────────── */

/* Button lift & focus ring */
.btn {
    transition: transform 0.16s ease, box-shadow 0.16s ease !important;
}
.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--sts-shadow-sm);
}
.btn:focus-visible {
    outline: 2px solid var(--sts-focus-ring, rgba(102,126,234,.5));
    outline-offset: 2px;
    box-shadow: none;
}
.btn:active {
    transform: translateY(0);
    box-shadow: var(--sts-shadow-xs);
}

/* Form control focus ring via token */
.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem var(--sts-focus-ring, rgba(102,126,234,.25));
}

/* List-group interactive items */
.list-group-item-action {
    transition: background 0.12s ease;
}

/* Badge subtle pulse on new notification */
@keyframes sts-badge-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(220,53,69,.4); }
    70%  { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,53,69,0); }
}
.badge.sts-pulse { animation: sts-badge-pulse 1.5s ease-out infinite; }

/* ─────────────────────────────────────────────────────────
   PHASE 9 — MOBILE UI PASS
   ───────────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
    /* Cards stack with consistent gap */
    .card { margin-bottom: 1rem !important; }
    .card > .card-body { padding: 1rem; }
    .card .card-header { padding: 0.75rem 1rem; }

    /* Tables: mobile ensures scrolling (already defined globally, kept for specificity) */
    .table-responsive { overflow-x: auto; }

    /* Hero metrics single column */
    .sts-hero-metrics {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .sts-metric-tile__value { font-size: 1.35rem; }

    /* Info boxes compact on mobile */
    .info-box { min-height: 100px; }
    .info-box-number { font-size: 1.5rem; }

    /* Chat input always at bottom */
    .chat-input-bar {
        position: sticky;
        bottom: 0;
        z-index: 10;
    }

    /* Navbar sticky on mobile */
    .navbar { position: sticky; top: 0; z-index: 1030; }

    /* Leaderboard: hide less-critical columns */
    .lb-col-hide-sm { display: none !important; }

    /* Button groups: wrap on mobile */
    .d-flex.gap-1 { flex-wrap: wrap; }

    /* Filter section on mobile */
    .filter-section { padding: 1rem !important; border-radius: 0.75rem; }

    /* Page title smaller */
    .page-title { font-size: 1.25rem !important; }

    /* Pagination wraps */
    .pagination { flex-wrap: wrap; gap: 0.2rem; }
}

@media (max-width: 575.98px) {
    /* Single column metric tiles */
    .sts-hero-metrics { grid-template-columns: 1fr; }

    /* Full width buttons in action areas */
    .sts-btn-stack .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Modal full width */
    .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }
}

/* Dark mode override for metric tiles */
[data-bs-theme="dark"] .sts-metric-tile {
    background: var(--sts-surface-elevated, #1e2533);
    border-color: var(--sts-border-soft, rgba(255,255,255,.06));
}
[data-bs-theme="dark"] .sts-metric-tile__bg-icon { opacity: 0.05; }

/* Dark mode: leaderboard row tints */
[data-bs-theme="dark"] .leaderboard-table tr.lb-rank-1 td { background: rgba(255,215,0,.06) !important; }
[data-bs-theme="dark"] .leaderboard-table tr.lb-rank-2 td { background: rgba(192,192,192,.06) !important; }
[data-bs-theme="dark"] .leaderboard-table tr.lb-rank-3 td { background: rgba(205,127,50,.06) !important; }

/* ─────────────────────────────────────────────────────────
   NOTIFICATIONS — unread item highlight (token-safe)
   ───────────────────────────────────────────────────────── */
.sts-unread-item {
    background: var(--sts-bg-elevated, rgba(102,126,234,.06)) !important;
    border-left: 3px solid #667eea;
}
[data-bs-theme="dark"] .sts-unread-item {
    background: rgba(102,126,234,.10) !important;
    border-left-color: #8fa8f8;
}

/* ================================================
   MOBILE BOTTOM NAVIGATION
   App-like 5-tab bottom bar — visible on screens < 992px.
   Desktop is unaffected (Bootstrap d-lg-none handles hiding).
   ================================================ */

/* ── Bottom tab bar shell ── */
.sts-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1031;            /* above sticky tables, below modals/offcanvas */
    display: flex;
    align-items: stretch;
    background: var(--sts-bg-surface, #ffffff);
    border-top: 1px solid var(--sts-border-subtle, #e9ecef);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
    /* iPhone home-bar safe area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    min-height: calc(60px + env(safe-area-inset-bottom, 0px));
}

/* ── Individual tab items ── */
.sts-mobile-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--sts-text-muted, #6c757d);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-width: 0;
    transition: color 0.15s ease;
}

.sts-mobile-nav__item:hover,
.sts-mobile-nav__item:focus {
    color: var(--sts-primary, #0d6efd);
    text-decoration: none;
    outline: none;
    background: rgba(102, 126, 234, 0.05);
}

.sts-mobile-nav__item.active {
    color: var(--sts-primary, #0d6efd);
}

/* Active: top indicator pill */
.sts-mobile-nav__item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--sts-primary, #0d6efd);
}

.sts-mobile-nav__icon {
    font-size: 1.35rem;
    line-height: 1;
    display: block;
    transition: transform 0.15s ease;
}

.sts-mobile-nav__item.active .sts-mobile-nav__icon {
    transform: scale(1.1);
}

.sts-mobile-nav__label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ── Content spacing adjustments for mobile bottom nav ── */
@media (max-width: 991.98px) {
    /* Push page content above the bottom nav */
    .sts-page-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 1.5rem) !important;
    }
    /* Footer bottom padding so it doesn't hide behind nav */
    .sts-footer {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.5rem) !important;
    }
    /* Move toast stack above the bottom nav */
    #sts-toast-container {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
    }
}

/* ── Mobile Menu Bottom Sheet (Bootstrap Offcanvas) ── */
.sts-mobile-menu-sheet {
    max-height: 88vh;               /* never covers entire screen */
    border-radius: 1.25rem 1.25rem 0 0;
    overflow: hidden;
}

.sts-mobile-menu-sheet .offcanvas-header {
    padding: 1.125rem 1.25rem 1rem;
    background: var(--sts-bg-surface, #ffffff);
    flex-shrink: 0;
}

.sts-mobile-menu-sheet .offcanvas-body {
    background: var(--sts-bg-canvas, #f8f9fa);
}

/* ── User info row in sheet header ── */
.sts-menu-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sts-gradient-primary, linear-gradient(135deg, #667eea, #764ba2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sts-menu-user-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sts-menu-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sts-text-primary, #212529);
    line-height: 1.3;
}

.sts-menu-user-email {
    font-size: 0.75rem;
    color: var(--sts-text-muted, #6c757d);
    line-height: 1.3;
}

/* ── Menu section: label + tile grid ── */
.sts-mobile-menu-section {
    padding: 1rem 1rem 0;
}

.sts-mobile-menu-section-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sts-text-muted, #6c757d);
    margin-bottom: 0.625rem;
    padding-left: 0.125rem;
}

.sts-mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
    margin-bottom: 1rem;
}

/* 2-column grid variant — used for sections with 2 items */
.sts-mobile-menu-grid--2col {
    grid-template-columns: repeat(2, 1fr);
}

/* Wide row-style tile — full-width, horizontal layout */
.sts-mobile-menu-tile--row {
    flex-direction: row;
    gap: 0.875rem;
    min-height: unset;
    padding: 0.875rem 1.125rem;
    justify-content: flex-start;
    width: 100%;
    border-radius: 0.875rem;
}

/* ── Menu tile (icon + label card) ── */
.sts-mobile-menu-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--sts-bg-surface, #ffffff);
    border-radius: 0.875rem;
    padding: 0.875rem 0.375rem;
    color: var(--sts-text-primary, #212529);
    text-decoration: none;
    font-size: 0.73rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    border: 1px solid transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    min-height: 74px;
}

.sts-mobile-menu-tile i {
    font-size: 1.4rem;
    display: block;
    line-height: 1;
}

.sts-mobile-menu-tile.active,
.sts-mobile-menu-tile:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--sts-primary, #0d6efd);
    border-color: rgba(102, 126, 234, 0.2);
    text-decoration: none;
}

.sts-mobile-menu-tile--danger {
    color: var(--bs-danger, #dc3545);
    background: rgba(220, 53, 69, 0.05);
}

.sts-mobile-menu-tile--danger:hover {
    background: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.2);
    color: var(--bs-danger, #dc3545);
}

/* ── Notification count badge inside tile ── */
/* Replaced by .sts-menu-tile-badge — see tile icon wrap rules below */
.sts-menu-notif-count {
    color: var(--sts-primary, #0d6efd);
    font-size: 0.7rem;
}

/* ── Menu tile icon wrap + pill badge overlay (4.3) ── */
.sts-menu-tile-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sts-menu-tile-badge {
    position: absolute;
    top: -5px;
    right: -9px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    background: var(--bs-danger, #dc3545);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 17px;
    border-radius: 9px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 0 0 2px var(--sts-bg-canvas, #f8f9fa);
}

/* ── Divider between sections ── */
.sts-mobile-menu-divider {
    height: 1px;
    background: var(--sts-border-subtle, #e9ecef);
    margin: 0 1rem;
}

/* ── Appearance row: theme + language toggles ── */
.sts-mobile-menu-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--sts-bg-surface, #ffffff);
    border-top: 1px solid var(--sts-border-subtle, #e9ecef);
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.sts-mobile-menu-row-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--sts-text-secondary, #495057);
    flex: 1;
    min-width: 80px;
}

/* ── Dark mode: mobile nav ── */
[data-bs-theme="dark"] .sts-mobile-nav {
    background: var(--sts-bg-surface, #1a1e2e);
    border-top-color: var(--sts-border, #2d3748);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.3);
}

/* ── Dark mode: bottom sheet ── */
[data-bs-theme="dark"] .sts-mobile-menu-sheet .offcanvas-header {
    background: var(--sts-bg-surface, #1a1e2e);
}

[data-bs-theme="dark"] .sts-mobile-menu-sheet .offcanvas-body {
    background: var(--sts-bg-canvas, #151822);
}

[data-bs-theme="dark"] .sts-mobile-menu-tile {
    background: var(--sts-bg-surface, #1a1e2e);
    color: var(--sts-text-primary, #e2e8f0);
}

[data-bs-theme="dark"] .sts-mobile-menu-tile.active,
[data-bs-theme="dark"] .sts-mobile-menu-tile:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.25);
}

[data-bs-theme="dark"] .sts-mobile-menu-divider {
    background: var(--sts-border, #2d3748);
}

[data-bs-theme="dark"] .sts-mobile-menu-row {
    background: var(--sts-bg-surface, #1a1e2e);
    border-top-color: var(--sts-border, #2d3748);
}

[data-bs-theme="dark"] .sts-menu-user-name {
    color: var(--sts-text-primary, #e2e8f0);
}

/* ── Chat tab badge (4.1) ── */
.sts-mobile-nav__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sts-mobile-nav__badge {
    position: absolute;
    top: -5px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    background: var(--bs-danger, #dc3545);
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 16px;
    border-radius: 8px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 0 0 2px var(--sts-bg-surface, #fff);
}

/* ── Reduced motion: disable all tab bar animations ── */
@media (prefers-reduced-motion: reduce) {
    .sts-mobile-nav__item,
    .sts-mobile-nav__icon,
    .sts-mobile-menu-tile {
        transition: none;
    }
    .sts-mobile-nav__item.active .sts-mobile-nav__icon {
        transform: none;
    }
}

/* ── 4.5: Active tab micro-animation ── */
.sts-mobile-nav__item .sts-mobile-nav__icon {
    transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), color 0.15s ease;
}

.sts-mobile-nav__item.active .sts-mobile-nav__icon {
    transform: scale(1.18) translateY(-1px);
}

.sts-mobile-nav__item .sts-mobile-nav__label {
    transition: color 0.15s ease, font-weight 0.15s ease;
}

.sts-mobile-nav__item.active .sts-mobile-nav__label {
    font-weight: 700;
}

/* ── 4.6: Menu grid — 4 columns on landscape phones & wider mobile ── */
/* Landscape / wider mobile: 4-col for default 3-col grids */
@media (max-width: 991.98px) and (orientation: landscape),
       (min-width: 480px) and (max-width: 991.98px) {
    .sts-mobile-menu-grid:not(.sts-mobile-menu-grid--2col) {
        grid-template-columns: repeat(4, 1fr);
    }
    /* 2-col stays 2-col on landscape */
    .sts-mobile-menu-grid--2col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* restore 3-col on portrait narrow phones (< 480px) */
@media (max-width: 479.98px) and (orientation: portrait) {
    .sts-mobile-menu-grid:not(.sts-mobile-menu-grid--2col) {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* =======================================================
   UI AUDIT PASS — Mobile Optimization & Visual Consistency
   Applied: 2026-03 polish pass
   ======================================================= */

/*
  Design System Rule:
  Heading sizes scale down slightly on mobile
  to maintain visual balance and avoid oversized text blocks.
*/
@media (max-width: 767.98px) {
    /* Admin card header h3 — normalize on mobile */
    .card .card-header h3,
    .card .card-header h3.card-title {
        font-size: 1rem;
        line-height: 1.35;
    }

    /* Card header h5 — keep readable */
    .card .card-header h5 {
        font-size: 0.9375rem;
    }

    /* Empty state icons don't need to be quite as large on mobile */
    .sts-empty__icon { font-size: 2.75rem; }
    .sts-empty__title { font-size: 1rem; }
}

@media (max-width: 575.98px) {
    /* Very small phones: breadcrumb items may need to wrap */
    .sts-breadcrumb {
        font-size: 0.7rem;
    }

    /* Remove excess radius inside cards on tiny screens */
    .table-responsive {
        border-radius: 0;
    }

    /* Filter forms: stack vertically on tiny screens */
    .d-flex.flex-wrap.gap-2.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
    }
    .d-flex.flex-wrap.gap-2.align-items-center .form-control,
    .d-flex.flex-wrap.gap-2.align-items-center .form-select {
        width: 100%;
    }
}

/*
  Design System Rule:
  Minimum touch target of 32px height for small buttons.
  Prevents mis-taps on mobile.
*/
.btn-sm {
    min-height: 2rem; /* 32px minimum touch target */
}

/*
  Design System Rule:
  Focus-visible outlines must be visible on all interactive elements.
  Required for keyboard navigation accessibility.
*/
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--sts-focus-ring, rgba(102,126,234,.65));
    outline-offset: 2px;
}

/*
  Design System Rule:
  table-responsive border-radius is removed to 0 on mobile
  so content flows edge-to-edge inside cards (see above).
  On desktop, keep the card-level radius.
*/

/* Visual consistency: normalize card-header h3 desktop font-size */
.card .card-header h3.card-title {
    font-size: 1.05rem;
    font-weight: 600;
}

/* Consistent icon-only button sizing — btn-group actions in admin tables */
.btn-group.btn-group-sm > .btn {
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
}

/* Stat tile: ensure 2-col grid on small mobile doesn't overflow */
@media (max-width: 374.98px) {
    /* Sub-375px (very small): stack stat tiles to single column if needed */
    .sts-metric-tile { min-height: auto; }
}

/* Dark mode: ensure focus rings remain visible */
[data-bs-theme="dark"] a:focus-visible,
[data-bs-theme="dark"] button:focus-visible,
[data-bs-theme="dark"] [role="button"]:focus-visible {
    outline-color: rgba(143,168,248,.75);
}

/* ── Mobile table density: compact font & padding on small screens ──
   Group tables on mobile only show 3–4 columns at default size.
   Scale down text and cell padding so more columns are readable.
*/
@media (max-width: 575.98px) {
    .table-responsive .table th,
    .table-responsive .table td,
    .table-responsive > table th,
    .table-responsive > table td {
        font-size: 0.72rem !important;
        padding: 0.35rem 0.45rem !important;
        white-space: nowrap;
    }
    /* Allow table-responsive to scroll horizontally without text wrapping */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}
