/* ═══════════════════════════════════════════
   RynSolution Partners Portal
   Navy (#1C2B4A) + Emerald (#10B981) accent
═══════════════════════════════════════════ */
:root {
    --p-primary: #1C2B4A;
    --p-primary-light: #2E4A6E;
    --p-accent: #10B981;
    --p-accent-hover: #059669;
    --p-gold: #C9A84C;
    --p-bg: #F8FAFB;
    --p-surface: #FFFFFF;
    --p-border: #E2E8F0;
    --p-text: #1E293B;
    --p-text-muted: #64748B;
    --p-text-light: #94A3B8;
    --p-radius: 12px;
    --p-radius-sm: 8px;
    --p-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --p-shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --sidebar-width: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--p-bg);
    color: var(--p-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--p-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-logo svg { color: var(--p-accent); }

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    margin: 2px 0.5rem;
    border-radius: var(--p-radius-sm);
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: var(--p-accent);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.nav-logout:hover { background: rgba(239,68,68,0.15); color: #F87171; }

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.visible { display: block; opacity: 1; }

/* ── Main wrapper ── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--p-surface);
    border-bottom: 1px solid var(--p-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius-sm);
    padding: 6px;
    cursor: pointer;
    color: var(--p-text);
}

.topbar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--p-primary);
    flex: 1;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p-primary), var(--p-primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--p-text);
}

/* ── Content ── */
.content {
    flex: 1;
    padding: 1.75rem 2rem 3rem;
    max-width: 1200px;
    width: 100%;
}

/* ── Referral Link Section ── */
.ref-link-section { margin-bottom: 1.5rem; }

.ref-link-card {
    background: linear-gradient(135deg, var(--p-primary) 0%, var(--p-primary-light) 100%);
    border-radius: var(--p-radius);
    padding: 1.75rem 2rem;
    color: #fff;
}

.ref-link-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.ref-link-info p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 1rem;
}

.ref-link-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--p-radius-sm);
    padding: 0.6rem 0.75rem 0.6rem 1rem;
}

.ref-link-url {
    flex: 1;
    font-size: 0.88rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: rgba(255,255,255,0.9);
    word-break: break-all;
    background: none;
}

.ref-code-badge {
    margin-top: 0.75rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.5);
}

.ref-code-badge strong { color: var(--p-gold); }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 1.25rem;
    box-shadow: var(--p-shadow);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.blue { background: rgba(59,130,246,0.1); color: #3B82F6; }
.stat-icon.green { background: rgba(16,185,129,0.1); color: #10B981; }
.stat-icon.gold { background: rgba(201,168,76,0.1); color: #C9A84C; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--p-primary);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.82rem;
    color: var(--p-text-muted);
    font-weight: 500;
    margin-top: 0.15rem;
}

.stat-sub {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--p-border);
    font-size: 0.78rem;
    color: var(--p-text-light);
}

.stat-sub svg { color: var(--p-accent); }

/* ── Cards ── */
.card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    box-shadow: var(--p-shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--p-border);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--p-primary);
}

.card-body { padding: 1.25rem 1.5rem; }

/* ── Dashboard grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dashboard-grid .card { margin-bottom: 0; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--p-text-light);
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--p-border);
    white-space: nowrap;
}

.table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--p-text);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--badge-color) 12%, transparent);
    color: var(--badge-color);
    white-space: nowrap;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--p-radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--p-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--p-primary-light); }

.btn-accent {
    background: var(--p-accent);
    color: #fff;
}
.btn-accent:hover { background: var(--p-accent-hover); }
.btn-accent.copied { background: var(--p-accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--p-primary);
    border: 1px solid var(--p-border);
}
.btn-ghost:hover { background: #f1f5f9; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Filter Bar ── */
.filter-bar { margin-bottom: 1rem; }

.filter-tabs {
    display: flex;
    gap: 0.35rem;
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 0.35rem;
    overflow-x: auto;
}

.filter-tab {
    padding: 0.5rem 1rem;
    border-radius: var(--p-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--p-text-muted);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-tab:hover { background: #f1f5f9; color: var(--p-text); }

.filter-tab.active {
    background: var(--p-primary);
    color: #fff;
}

.filter-tab .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(0,0,0,0.08);
    margin-left: 0.3rem;
}

.filter-tab.active .count { background: rgba(255,255,255,0.2); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--p-border);
    margin-top: 1rem;
}

.page-link {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--p-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--p-text-muted);
    transition: all 0.2s ease;
}

.page-link:hover { background: #f1f5f9; }
.page-link.active {
    background: var(--p-primary);
    color: #fff;
}

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--p-text-light);
}

.empty-state svg { opacity: 0.4; }

.empty-state h3 {
    font-size: 1rem;
    color: var(--p-text-muted);
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 360px;
}

.empty-state.small { padding: 2rem 1rem; }

/* ── Info Grid (Commissions) ── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.info-item {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 1rem;
    background: var(--p-bg);
    border-radius: var(--p-radius-sm);
    border: 1px solid var(--p-border);
}

.info-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28,43,74,0.06);
    border-radius: 10px;
    color: var(--p-primary);
}

.info-item strong {
    display: block;
    font-size: 0.9rem;
    color: var(--p-primary);
    margin-bottom: 0.2rem;
}

.info-item p {
    font-size: 0.82rem;
    color: var(--p-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ── Profile ── */
.profile-summary {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--p-border);
}

.profile-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p-primary), var(--p-primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    flex-shrink: 0;
}

.profile-details h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--p-primary);
}

.profile-details > p { font-size: 0.9rem; }

.profile-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.4rem;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.profile-info-item {
    padding: 0.85rem 1rem;
    background: var(--p-bg);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius-sm);
}

.profile-info-item .label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--p-text-light);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.profile-info-item .value {
    display: block;
    font-size: 0.9rem;
    color: var(--p-text);
}

.ref-link-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ref-link-inline code {
    font-size: 0.78rem;
    color: var(--p-primary);
    word-break: break-all;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--p-text);
    margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--p-text);
    background: var(--p-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--p-primary);
    box-shadow: 0 0 0 3px rgba(28,43,74,0.08);
}

.form-group small {
    display: block;
    font-size: 0.78rem;
    color: var(--p-text-light);
    margin-top: 0.3rem;
}

.input-disabled {
    background: #f1f5f9 !important;
    color: var(--p-text-muted) !important;
    cursor: not-allowed;
}

.input-icon {
    position: relative;
}

.input-icon svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--p-text-light);
    pointer-events: none;
}

.input-icon input {
    padding-left: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--p-radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.alert-error {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.alert-success {
    background: #F0FDF4;
    color: #16A34A;
    border: 1px solid #BBF7D0;
}

.alert svg { flex-shrink: 0; }

/* ── Text utils ── */
.text-muted { color: var(--p-text-muted) !important; }
.text-success { color: #10B981 !important; }

/* ── Auth Pages ── */
.auth-page {
    background: linear-gradient(135deg, #111D33 0%, #1C2B4A 50%, #2A3F66 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--p-surface);
    border-radius: 16px;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-card-wide { max-width: 520px; }
.auth-card-wide + .auth-wrapper { max-width: 520px; }
body.auth-page .auth-wrapper { max-width: 520px; }

.auth-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--p-primary), var(--p-primary-light));
    border-radius: 16px;
    color: #fff;
}

.auth-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--p-primary);
    margin-bottom: 0.3rem;
}

.auth-header p {
    font-size: 0.9rem;
    color: var(--p-text-muted);
}

.auth-form .btn { margin-top: 0.5rem; }

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--p-border);
}

.auth-footer p {
    font-size: 0.88rem;
    color: var(--p-text-muted);
}

.auth-footer a {
    color: var(--p-primary);
    font-weight: 600;
}

.auth-footer a:hover { color: var(--p-accent); }

/* ── Benefits preview (register) ── */
.benefits-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: var(--p-radius-sm);
    margin-bottom: 0.5rem;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #166534;
}

.benefit-item svg { flex-shrink: 0; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }

    .main-wrapper { margin-left: 0; }

    .topbar .menu-toggle { display: flex; }
    .topbar { padding: 0.85rem 1.25rem; }

    .content { padding: 1.25rem; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }

    .ref-link-box { flex-direction: column; align-items: stretch; }

    .user-name { display: none; }

    .profile-info-grid { grid-template-columns: 1fr; }
    .profile-summary { flex-direction: column; text-align: center; }

    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid,
    .stats-grid-3 { grid-template-columns: 1fr; }

    .filter-tabs { gap: 0.2rem; }
    .filter-tab { padding: 0.4rem 0.7rem; font-size: 0.8rem; }

    .table { font-size: 0.82rem; }
    .table th, .table td { padding: 0.55rem 0.5rem; }

    .auth-card { padding: 1.75rem 1.25rem 1.5rem; }
}
